title: Why do methods on pointers work when the pointer is a variable, but not otherwise?
body: <p>When running the following code:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
  )
  
  type Bar struct {
      name string
  }
  
  func (foo Bar) testFunc() {
      fmt.Println(foo.name)
  }
  
  func doTest(pointer *Bar) {
      pointer.testFunc() // run `testFunc` on the pointer (even though it expects a value of type `Bar`, not `*Bar`)
  }
  
  func main() {
      var baz Bar = Bar{
          name: "Johnny Appleseed",
      }
  
      doTest(&amp;baz) // send a pointer of `baz` to `doTest()`
  }
  </code></pre>
  
  <p>The output reads: <code>Johnny Appleseed</code>. I would have thought I would have encountered an error for calling <code>testFunc()</code> on a pointer.</p>
  
  <p>After that, I tried switching out <code>doTest(&amp;baz)</code> for <code>&amp;baz.testFunc()</code>. Then I received the error:</p>
  
  <pre><code>tmp/sandbox667065035/main.go:24: baz.testFunc() used as value
  </code></pre>
  
  <p>Why do I only get the error when calling <code>baz.testFunc()</code> directly instead of through another function? Wouldn't calling <code>doTest(&amp;baz)</code> and <code>&amp;baz.testFunc()</code> do the exact same thing, as <code>doTest(pointer *Bar)</code> simply calls <code>pointer.testFunc()</code>?</p>
  
  <p><em><a href="https://play.golang.org/p/xotjr1iKOt" rel="nofollow noreferrer">Playground 1 (<code>doTest(&amp;baz)</code>)</a></em></p>
  
  <p><em><a href="https://play.golang.org/p/Tqg7LSl8LA" rel="nofollow noreferrer">Playground 2 (<code>&amp;baz.testFunc()</code>)</a></em></p>