mila 이 gist를 수정했습니다 2 years ago. 리비전으로 이동
변경 사항 없음
mila 이 gist를 수정했습니다 2 years ago. 리비전으로 이동
1 file changed
gistfile1.txt 이름 변경됨 print-json.go
변경 없이 파일 이름만 변경됨
mila 이 gist를 수정했습니다 2 years ago. 리비전으로 이동
1 file changed, 12 insertions
gistfile1.txt(파일 생성됨)
| @@ -0,0 +1,12 @@ | |||
| 1 | + | //lint:ignore U1000 (dev-only) | |
| 2 | + | func printJSON(i interface{}, prefix ...string) { | |
| 3 | + | pre := fmt.Sprintf("%T>>>", i) | |
| 4 | + | if len(prefix) == 1 { | |
| 5 | + | pre = prefix[0] + ">" | |
| 6 | + | } | |
| 7 | + | data, err := json.MarshalIndent(i, pre+" ", " ") | |
| 8 | + | if err != nil { | |
| 9 | + | panic(err) | |
| 10 | + | } | |
| 11 | + | fmt.Println(pre + " " + string(data)) | |
| 12 | + | } | |