先看效果:
aInt := 1
bStr := `sf`
cMap := map[string]interface{}{"name": "z", "age": 14}
dArray := []interface{}{&cMap, aInt, bStr}
dump.Dump(aInt, &aInt, &bStr, bStr, cMap, dArray, cMap["name"], dArray[2], dArray[aInt])
https://i.imgur.com/bBV53DC.jpg

相比 print 会提供几个信息:
- 代码行号
- 变量名
- 指针类型的展开(跟 json 一样,不支持循环引用)
为什么要搞这个东西?
之前调 Go 的代码的时候用 print,但是打出来的日志总是不知道在哪,经常还会看到别人使用 print("===ABC===")。
后来用 GoLand 的 postfix 功能做了一键打印 json 。但脱离了 GoLand 就不太好使了,于是决定实现一个库,哪都能用。
再发一个 postfix 的方式,在 Goland 里还是挺好用的
https://i.imgur.com/WQaQFHq.gif

Repo 地址(好用的话不要忘了赏我一个 star 😂)
