title: Comparing pointers in Go
body: <p>I am reading in my Go book that pointers are comparable. It says: two pointers are equal if and only if they Point to the same variable or both are nil.</p>
  
  <p>So why is my following code printing 'true' when comparing two pointers which are pointing to two different variables?</p>
  
  <pre><code>func main() {
      var p = f()
      var q = f2()
      fmt.Println(*p == *q) // why true?
  }
  
  func f() *int {
      v := 1
      return &amp;v
  }
  
  func f2() *int {
      w := 1
      return &amp;w
  }
  </code></pre>