I have the following code:
package main
import "fmt"
type MyStruct struct {
}
func main() {
a := &MyStruct{}
b := &MyStruct{}
fmt.Println(a == b)
fmt.Println(*a == *b)
}
Which as expected outputs
false
true
But, if I add two Print statements at the end like this:
package main
import "fmt"
type MyStruct struct {
}
func main() {
a := &MyStruct{}
b := &MyStruct{}
fmt.Println(a == b)
fmt.Println(*a == *b)
fmt.Println(&a)
fmt.Println(&b)
}
The output becomes something I did not expect:
true
true
0xc0000ae018
0xc0000ae020
Why does it become true
in the first case?