In Golang, is there an easy way to print for debugging the dereferenced pointers given a slice of pointers to structs?
1条回答 默认 最新
- dongqian3750 2014-10-24 00:57关注
If you don't want to use unsafe and an external package.. you can
range
over it yourself:for _, p := range people { fmt.Printf("%+v ", p) }
Output:
&{name:Simon age:25} &{name:Bob age:31}
Working sample: http://play.golang.org/p/aVw0rhQNuk
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报