title: Go SQL, scanning a row as a slice?
body: <p><strong>closing note:
  This question does not ask &quot;how can I find the number of columns returned?&quot; which is len(row.Columns()). It is asking a Go-related question concerning the <code>rows.Scan()</code> function.</strong></p>
  <p>How can I extract all the columns in a row into a slice or equivalent?  For example</p>
  <pre><code>    rows, err := db.Query(&quot;select * from foo&quot;)
      for rows.Next() {
          fmt.Printf(&quot;%+v\n&quot;, rows)
  </code></pre>
  <p>I would like to extract the data in <code>lastcols</code> as a slice.</p>
  <pre><code>&amp;{dc:0xc000486000 releaseConn:0x5e20c0 rowsi:0xc0000cf180 cancel:&lt;nil&gt;
  closeStmt:&lt;nil&gt; closemu:{w:{state:0 sema:0} writerSem:0
  readerSem:0 readerCount:0 readerWait:0} closed:false lasterr:&lt;nil&gt;
  lastcols:[abc 123 foo {wall:0 ext:0 loc:0xc0000ec000}]}
  </code></pre>
  <p>context:</p>
  <ul>
  <li>for debugging, I would like to <code>select * from sometable</code> and display the results without knowing the table format in advance.</li>
  <li>github.com/lib/pg SQL driver.</li>
  </ul>