title: function to return an Interface
body: <p>How come I can say that the result of CreateLion(), a pointer to a struct that implements the Cat interface, is an instance of the Cat interface, and yet I cannot say that CreateLion() is of type &quot;function that returns the Cat interface.&quot;</p>
  <p>What is the standard Golang approach to achieving this type of behavior?</p>
  <pre><code>package main
  
  import &quot;fmt&quot;
  
  func main() {
      var lion Cat := CreateLion()
      lion.Meow()
  
      // this line breaks. Why?
      var cf CatFactory = CreateLion
  }
  
  type Cat interface {
      Meow()
  }
  
  type Lion struct {}
  func (l Lion) Meow() {
      fmt.Println(&quot;Roar&quot;)
  }
  
  // define a functor that returns a Cat interface
  type CatFactory func() Cat
  
  // define a function that returns a pointer to a Lion struct
  func CreateLion() *Lion {
      return &amp;Lion{}
  }
  </code></pre>