title: Postgres SELECT in Go returns all columns as string (using pq and database/sql)
body: <p>I'm doing a select in Go using the <a href="http://golang.org/pkg/database/sql" rel="noreferrer">database/sql</a> package and the <a href="http://github.com/lib/pq" rel="noreferrer">pq</a> Postgres driver:</p>
  
  <pre><code>rows, err := db.Query("SELECT (name, age) FROM people WHERE id = 1")
  </code></pre>
  
  <p>I tried retrieving the values in the normal way:</p>
  
  <pre><code>rows.Next()
  name := ""
  age := 0
  err = rows.Scan(&amp;name, &amp;age)
  </code></pre>
  
  <p>but I got the error:</p>
  
  <pre><code>sql: expected 1 destination arguments in Scan, not 2
  </code></pre>
  
  <p>The documentation for <a href="http://golang.org/pkg/database/sql/#Rows.Scan" rel="noreferrer">sql.(*Rows).Scan</a> says that you can pass a byte slice pointer and it will be filled with the raw results. So I did this:</p>
  
  <pre><code>b := make([]byte, 1024*1024)
  rows.Scan(&amp;b)
  fmt.Println(string(b))
  </code></pre>
  
  <p>which succeeded, printing:</p>
  
  <pre><code>(John,18)
  </code></pre>
  
  <p>So I looked at the source code for <a href="http://golang.org/src/pkg/database/sql/sql.go?s=40013:40060#L1541" rel="noreferrer">sql.(*Rows).Scan</a>, and it turns out that the error is returned if the number of arguments doesn't match the number of results returned by the database driver (which makes sense). So, for some reason, the pq driver seems to be returning the result set as a single value. Why would this be?</p>