Skip to content

Instantly share code, notes, and snippets.

@wttw
Created November 7, 2016 20:51
Show Gist options
  • Save wttw/e7f5ea70dbaeccf8340d29827aa87eb4 to your computer and use it in GitHub Desktop.
Save wttw/e7f5ea70dbaeccf8340d29827aa87eb4 to your computer and use it in GitHub Desktop.
columnNames, err := rows.Columns()
if err != nil {
log.Fatalln(err) // or whatever error handling is appropriate
}
columns := make([]interface{}, len(columnNames))
columnPointers := make([]interface{}, len(columnNames))
for i := 0; i < len(columnNames); i++ {
columnPointers[i] = &columns[i]
}
if err := rows.Scan(columnPointers...); err != nil {
log.Fatalln(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment