Created
January 19, 2020 10:26
-
-
Save guumaster/77e05469b9d4faedff1b7f1d18b054b9 to your computer and use it in GitHub Desktop.
golang printJSON debug
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
// printJSON prints v as JSON encoded with indent to stdout. It panics on any error. | |
func printJSON(v interface{}) { | |
w := json.NewEncoder(os.Stdout) | |
w.SetIndent("", "\t") | |
err := w.Encode(v) | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment