Last active
March 2, 2021 11:25
-
-
Save serveba/4ed2a80ff019ef7e9f928d37fa628f96 to your computer and use it in GitHub Desktop.
golang struct pretty print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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