title: Value receiver vs. pointer receiver
body: <p>It is very unclear for me in which case I would want to use a value receiver instead of always using a pointer receiver.</p>
  <p>To recap from the docs:</p>
  <pre><code>type T struct {
      a int
  }
  func (tv  T) Mv(a int) int         { return 0 }  // value receiver
  func (tp *T) Mp(f float32) float32 { return 1 }  // pointer receiver
  </code></pre>
  <p>The <strong>docs</strong> also say &quot;For types such as basic types, slices, and small structs, a value receiver is very cheap so unless the semantics of the method requires a pointer, a value receiver is efficient and clear.&quot;</p>
  <p><strong>First point</strong> they docs say a value receiver is &quot;very cheap&quot;, but the question is whether it is cheaper than a pointer receiver. So I made a small benchmark <a href="https://gist.github.com/chrisport/f28674850ffc3d9238f8" rel="noreferrer">(code on gist)</a> which showed me, that pointer receiver is faster even for a struct that has only one string field. These are the results:</p>
  <pre><code>// Struct one empty string property
  BenchmarkChangePointerReceiver  2000000000               0.36 ns/op
  BenchmarkChangeItValueReceiver  500000000                3.62 ns/op
  
  
  // Struct one zero int property
  BenchmarkChangePointerReceiver  2000000000               0.36 ns/op
  BenchmarkChangeItValueReceiver  2000000000               0.36 ns/op
  </code></pre>
  <p><em>(Edit: Please note that second point became invalid in newer go versions, see comments.)</em></p>
  <p><strong>Second point</strong> the docs say that a value receiver it is &quot;efficient and clear&quot; which is more a matter of taste, isn't it? Personally I prefer consistency by using the same thing everywhere. Efficiency in what sense? Performance wise it seems pointer are almost always more efficient. Few test-runs with one int property showed minimal advantage of Value receiver (range of 0.01-0.1 ns/op)</p>
  <p>Can someone tell me a case where a value receiver clearly makes more sense than a pointer receiver? Or am I doing something wrong in the benchmark? Did I overlook other factors?</p>