title: Different pointers are equal?
body: <p>I'm trying to represent some points on a 2d plane as pairs of integers. I want the points to be immutable (pass-by-value), but also for each to have a unique identity. To accomplish this, I made a struct with two <code>int</code>s and a <code>*string</code>. This works fine:</p>
  
  <pre><code>package main
  import "fmt"
  func main() {
      s1 := ""
      s2 := ""
      p := Point{1,2,&amp;s1}
      p2 := Point{1,2,&amp;s2}
      fmt.Println(p2==p) // want false
  }
  type Point struct{X int; Y int; id *string}
  </code></pre>
  
  <p>
  
  <pre><code>$ go run a.go
  false
  </code></pre>
  
  <p>Since the <code>string</code> isn't actually used for anything (I only care about telling whether two points are the same), it seems like the canonical solution for making a unique reference like this would be to use a pointer to <code>struct{}</code> instead:</p>
  
  <pre><code>package main
  import "fmt"
  func main() {
      s1 := struct{}{}
      s2 := struct{}{}
      p := Point{1,2,&amp;s1}
      p2 := Point{1,2,&amp;s2}
      fmt.Println(p2==p) // want false
  }
  type Point struct{X int; Y int; id *struct{}}
  </code></pre>
  
  <p>However, now the two pointers are equal:</p>
  
  <pre><code>$ go run a.go
  true
  </code></pre>
  
  <p>Why? Can this happen with strings as well? Should I use UUIDs instead?</p>