Is there any way of printing a struct with mixed value types, including pointer types, such that all value are shown? For 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
", t)
}
I want something 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 you could use for that functionality. You could implement Stringer on your struct and have full control over how the struct is printed.