go - Printing all values of a struct with mixed values? -
is there way of printing struct mixed value types, including pointer types, such value shown? example:
package main import ( "fmt" ) type test struct { str string ptr *string } func main() { s := "some string" p := &s t := test{ str: s, ptr: p, } fmt.printf("%#v\n", t) }
i want like: main.test{str:"some string", ptr:(*string)("some string"}
instead of: main.test{str:"some string", ptr:(*string)(0x1040a120)}
there's no fmt verb use functionality. implement stringer on struct , have full control on how struct printed.
Comments
Post a Comment