Published on

Go Debugging Structs

Authors

In Go I needed to debug what was happening to a struct in my code. You can use methods that allow formatting for example fmt.Sprintf but I was not sure how to do this for a struct %s did not work. After quick search I came across this answer. Basically you use %+v which I assume means variable so with a Sprintf it would be:

stringifiedStruct := fmt.Sprintf("myStruct stringified is %+v", myStruct)