Here is the go code
package main
func main() {
var ax [2]int
ax[0] = 22
ax[1] = 99
bx := ax
cx := &ax
fmt.Println(ax)
fmt.Println(bx)
fmt.Println(cx)
fmt.Printf("%p
", cx)
}
When I execute it, it gives me the following output
PS C:\personal\gospace> ./bin/test
[22 99]
[22 99]
&[22 99]
0xc0420381d0
cx := &ax
rightly interpreted cx as pointer. But when I print cx it prints &[22 99]
and when I print &ax[0]
or %p
formatter for cx it rightly prints the address. Why is this behavior?