Skip to content

Instantly share code, notes, and snippets.

@matthewoestreich
Created November 28, 2020 07:14
Show Gist options
  • Save matthewoestreich/fc3a4ea22f9eda71060596020d8f9330 to your computer and use it in GitHub Desktop.
Save matthewoestreich/fc3a4ea22f9eda71060596020d8f9330 to your computer and use it in GitHub Desktop.
Pretty Print JSON strings in Golang
func prettyPrint(i interface{}) {
prettyJSON, err := json.MarshalIndent(i, "", " ")
if err != nil {
fmt.Printf("Error : %s \n", err.Error())
}
fmt.Printf("%s\n", string(prettyJSON))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment