Skip to content

Instantly share code, notes, and snippets.

@guumaster
Created January 19, 2020 10:26
Show Gist options
  • Save guumaster/77e05469b9d4faedff1b7f1d18b054b9 to your computer and use it in GitHub Desktop.
Save guumaster/77e05469b9d4faedff1b7f1d18b054b9 to your computer and use it in GitHub Desktop.
golang printJSON debug
// 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