title: golang API interface, what am I missing?
body: <p>I want to create an interface to make it easy to add new storage backends.</p>
  
  <pre><code>package main
  
  // Storage is an interface to describe storage backends
  type Storage interface {
      New() (newStorage Storage)
  }
  
  // File is a type of storage that satisfies the interface Storage
  type File struct {
  }
  
  // New returns a new File
  func (File) New() (newFile Storage) {
      newFile = File{}
      return newFile
  }
  
  // S3 is a type of storage that satisfies the interface Storage
  type S3 struct {
  }
  
  // New returns a new S3
  func (S3) New() (newS3 S3) {
      newS3 = S3{}
      return newS3
  }
  
  func main() {
      // List of backends to choose from
      var myStorage map[string]Storage
      myStorage["file"] = File{}
      myStorage["s3"] = S3{}
  
      // Using one of the backends on demand
      myStorage["file"].New()
      myStorage["s3"].New()
  }
  </code></pre>
  
  <p>But it seems not possible to define and satisfy a function that should return an object that satisfies the interface itself as well.</p>
  
  <p>File.New() returns an object of type Storage which satisfies Storage.</p>
  
  <p>S3.New() returns an object of type S3.
  S3 should satisfies the interface Storage as well but I get this:</p>
  
  <pre><code>./main.go:32: cannot use S3 literal (type S3) as type Storage in assignment:
      S3 does not implement Storage (wrong type for New method)
          have New() S3
          want New() Storage
  </code></pre>
  
  <p>What am I doing wrong?
  I hope I am missing something basic here.</p>