Skip to content

Instantly share code, notes, and snippets.

@giuliano-macedo
Last active September 20, 2021 01:21
Show Gist options
  • Save giuliano-macedo/4a637b4bdd77a9292e7eef9b97b55a9d to your computer and use it in GitHub Desktop.
Save giuliano-macedo/4a637b4bdd77a9292e7eef9b97b55a9d to your computer and use it in GitHub Desktop.
print_json.go
package main
import (
"encoding/json"
"fmt"
)
func printJson(data interface{}) {
bs, err := json.MarshalIndent(data, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(bs))
}
func main() {
printJson(map[string]string{"Foo": "Hello", "Bar": "world"})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment