title: How do I print the pointer value of a Go object? What does the pointer value mean?
body: <p>I am just playing around with Go and do not yet have a good mental model of when structs are passed by value or by reference.</p>
  
  <p>This may be a very dumb question but I just want to experiment a bit and see if I am still working on the same object or I have made a copy of it (passed it by value).</p>
  
  <p>Is there a way to print the pointer (or internal id if pointer value is changed by gc) of an object?</p>
  
  <pre><code>package main
  
  import ( "runtime" )
  
  type Something struct {
      number int
      queue chan int
  }
  
  func gotest( s *Something, done chan bool ) {
      println( "from gotest:")
      println( &amp;s )
      for num := range s.queue {
          println( num )
          s.number = num
      }
      done &lt;- true
  }
  
  func main() {
      runtime.GOMAXPROCS(4)
      s := new(Something)
      println(&amp;s)
      s.queue = make(chan int)
      done := make(chan bool)
      go gotest(s, done)
      s.queue &lt;- 42
      close(s.queue)
      &lt;- done
      println(&amp;s)
      println(s.number)
  }
  </code></pre>
  
  <p>gives on my windows (8g compiled version):</p>
  
  <pre><code>0x4930d4
  from gotest:
  0x4974d8
  42
  0x4930d4
  42
  </code></pre>
  
  <p>Why does the pointer value from within the go routine show a different value? The quantity on the original object did get changed so it was working with the same object. Is there a way to see an object id that is persistent?</p>