title: Mocking database/sql structs in Go
body: <p>In testing database methods, I created a minimal wrapper over the database/sql package to allow me to test against interfaces instead of the difficult if not impossible to setup concrete classes.  But, I get the following error when I try to mock sql.Stmt:</p>
  
  <pre><code>cannot use *sql.Stmt as type IStmt in return argument:
      *sql.Stmt does not implement IStmt (wrong type for Query method)
              have Query(...interface {}) (*sql.Rows, error)
              want Query(...interface {}) (IRows, error)
  </code></pre>
  
  <p>Here are my interfaces:</p>
  
  <pre><code>type IStmt interface {
      Query(args ...interface{}) (IRows, error)
      QueryRow(args ...interface{}) IRow
  }
  
  type IRows interface {
      Columns() ([]string, error)
      Next() bool
      Close() error
      Scan(dest ...interface{}) error
      Err() error
  }
  </code></pre>
  
  <p>And here's the problem method:</p>
  
  <pre><code>func (c *DbConnection) Prepare(query string) (IStmt, error) {
      return c.conn.Prepare(query)
  }
  </code></pre>
  
  <p>I know that one of the beautiful things about Go is that you can create your own interface and any struct that implements it will automatically "implement" it without having to use the <code>implements</code> keyword in java or use the semicolon like in C# to subclass.  Why isn't it working with this return type?  Am I doing something wrong?</p>