Skip to content

Instantly share code, notes, and snippets.

@serveba
Last active March 2, 2021 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serveba/4ed2a80ff019ef7e9f928d37fa628f96 to your computer and use it in GitHub Desktop.
Save serveba/4ed2a80ff019ef7e9f928d37fa628f96 to your computer and use it in GitHub Desktop.
golang struct pretty print
# someStruct is a struct with other structs as fields
# printf will show all the tree struct on a human friendly format
prettyString, _ := json.MarshalIndent(someStruct, "", " ")
fmt.Printf("%s: %s\n", reflect.TypeOf(someStruct).Name(), prettyString)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment