title: Use 'comma ok' idiom or return pointer?
body: <p>Consider the following Go snippet:</p>
  
  <pre><code>func sheep() (int, bool) {
      return 1, true
  }
  
  func main() {
      if dolly, ok := sheep() {
           //do something
      }
  }
  </code></pre>
  
  <p>As I read on <a href="http://golang.org/doc/effective_go.html" rel="noreferrer">'Effective Go'</a> this is called the 'comma ok' idiom. As far as I can tell this is used to distinguish from a 'found' and 'not found' thing.</p>
  
  <p>The same can be achieved via:</p>
  
  <pre><code>type Sheep struct {}
  
  func sheep() *Sheep {
      return &amp;Sheep{}
  }
  
  func main() {
      if dolly := sheep(); dolly != nil {
           //do something
      }
  }
  </code></pre>
  
  <p>The latter example seems to fulfill the same purpose, perhaps even nicer. With the 'comma ok' example the assignment is only valid in the if block.</p>
  
  <p>Perhaps I'm missing some considerations. Which pattern is preferred? And why?</p>
  
  <p>A brief example: <a href="http://play.golang.org/p/ATxvle38iE" rel="noreferrer">http://play.golang.org/p/ATxvle38iE</a></p>