I'm quite confusing about the struct in Go.
This is the code: http://play.golang.org/p/b1NEh7JZoK
Why I could't get the address of a variable to a struct?
If I have two int variables, one stores value, one stores address(pointer), like this : http://play.golang.org/p/XhvKX-ifdn
I can get the actual address of these two variables, but why struct can't?
fmt.Println
prints things in a more readable format. If you want to actually see the addresses, use fmt.Printf
with %p
verb:
fmt.Printf("%p
", &a) // 0x10328000
fmt.Printf("%p -> %p
", &b, b) // 0x1030e0c0 -> 0x10328000