I’ve got a variable which is equal to a pointer of the following struct:
type Conn struct {
rwc io.ReadWriteCloser
l sync.Mutex
buf *bytes.Buffer
}
Thus
fmt.Printf("---*cn: %+vn", *cn)
returns
{rwc:0xc42000e080 l:{state:0 sema:0} buf:0xc42005db20}
How can I see the value at the addresses 0xc42000e080 and 0xc42005db20?
My end goal is to inspect this because it’s used when connecting to memcache and on the chance memcache breaks I’m trying to reestablish connection, and need to inspect this to solve it.
2
Answers
I am not sure why would you need a separate library for this. The straight forward answer is that you can directly dereference
rwc
inside the struct.So, you would do something like
Assuming
Conn
is imported and you don’t have access to the unexported fields with the standard selector expression you can use thereflect
package to bypass that limitation.https://play.golang.org/p/-6lWi1vYod