Skip to content

Instantly share code, notes, and snippets.

@vuduongtp
Last active October 26, 2022 02:51
Show Gist options
  • Save vuduongtp/ce5fdceb84bf6f48bc44acc5fdf74112 to your computer and use it in GitHub Desktop.
Save vuduongtp/ce5fdceb84bf6f48bc44acc5fdf74112 to your computer and use it in GitHub Desktop.
Golang - Pretty print object as JSON format
import (
"encoding/json"
"fmt"
"reflect"
)
func PrettyPrint(i interface{}) {
fmt.Printf("Type: %s\n", reflect.TypeOf(i))
s, _ := json.MarshalIndent(i, "", "\t")
fmt.Println(string(s))
fmt.Println("==============")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment