有一个很棒的软件包,称为go-spew。正是您想要的。
package mainimport ( "github.com/davecgh/go-spew/spew")type ( SomeStruct struct { Field1 string Field2 int Field3 *somePointer } somePointer struct { field string })func main() { s := SomeStruct{ Field1: "Yahoo", Field2: 500, Field3: &somePointer{"I want to see what is in here"}, } spew.Dump(s)}将为您提供以下输出:
(main.SomeStruct) { Field1: (string) "Yahoo", Field2: (int) 500, Field3: (*main.somePointer)(0x2102a7230)({ field: (string) "I want to see what is in here" })}


