In the example below I check the equality of two pointers
- The pointers are pointing to the same address
- They are not the same pointer
How do I check if two pointers are pointing to the same address? I do not want to check if the contents of both pointers are equal.
package main
import (
"fmt"
)
type Map struct {}
type Fragment struct {
Map *Map
}
func (m1 Map) NewFragment() (f Fragment) {
f.Map = &m1
return
}
var m Map = Map {}
func main() {
f := m.NewFragment()
fmt.Println(f.Map == &m) // false
fmt.Println(*f.Map == m) // true
}