Last active
September 20, 2021 01:21
-
-
Save giuliano-macedo/4a637b4bdd77a9292e7eef9b97b55a9d to your computer and use it in GitHub Desktop.
print_json.go
This file contains hidden or 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
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