On 04/03/2017 08:50 AM, oju...@gmail.com wrote:
> I built a little command line utility for running arbitrary sql queries.
> You use it like:
> 
>     runQuery "select * from myTable"
> 
> 
> Previously I have build similar tools in C and Java and I don't remember
> needing to code a hack to handle a variable number of columns.
> 
>     https://play.golang.org/p/6WOu1SzgcZ
> 

Just going from the documentation, rows.Scan() is a variadic function so
you should be able to do something like:

  cols, _ := rows.Columns()
  v := make([]interface{}, len(cols))
  err = rows.Scan(v...)

-ayan


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to