title: How do you pass a slice of *interface{} as arguments?
body: <p>I want to use <a href="https://golang.org/pkg/database/sql/#Rows.Scan" rel="nofollow noreferrer"><code>Scan()</code></a> in package <code>sql</code>, but the number of columns, and hence the number of arguments, will change at runtime. This is the signature of <code>Scan()</code>:</p>
  
  <pre><code>func (rs *Rows) Scan(dest ...interface{}) error
  </code></pre>
  
  <p>According to the documentation, <code>*interface{}</code> is one of the types accepted by <code>Scan()</code>. So I want to create a slice of <code>[]*interface{}</code> and that expand as arguments.</p>
  
  <p>This is what I thought would work:</p>
  
  <pre><code>func query(database *sql.DB) {
      rows, _ := database.Query("select * from testTable")
  
      for rows.Next() {
          data := make([]*interface{}, 2)
          err := rows.Scan(data...) // Compilation error
          fmt.Printf("%v%v\n", *data[0], *data[1])
          if err != nil {
              fmt.Println(err.Error())
          }
      }
  }
  </code></pre>
  
  <p>Compilation fails with <code>cannot use data (type []*interface {}) as type []interface {} in argument to rows.Scan</code>. I thought that <code>data...</code> would expand to <code>&amp;data[0], &amp;data[1]</code>, but apparently not. I don't understand the error message. <code>*interface{}</code> is compatible with <code>interface{}</code>, so why can't I expand the slice of pointers to interface types?</p>
  
  <p>This works:</p>
  
  <pre><code>func query(database *sql.DB) {
      rows, _ := database.Query("select * from testTable")
  
      for rows.Next() {
          data := make([]*interface{}, 2)
          err := rows.Scan(&amp;data[0], &amp;data[1]) // Only changed this line
          fmt.Printf("%v%v\n", *data[0], *data[1]) // Outputs "[48][116 101 120 116]"
          if err != nil {
              fmt.Println(err.Error())
          }
      }
  }
  </code></pre>
  
  <p>I can't use this however, because the number of columns is unknown at compile time. How can I write this code so that I can pass a variable number of <code>*interface{}</code> to <code>rows.Scan()</code>?</p>