Golang database/sql.Rows.Columns function example
package database/sql
Columns returns the column names. Columns returns an error if the rows are closed, or if the rows are from QueryRow and there was a deferred error.
Golang database/sql.Rows.Columns function usage example
var rows *sql.Rows
var cols []string
rows, err = dbmap.Db.Query("SELECT * FROM created_columns")
cols, err = rows.Columns() // <--- here
if err != nil || len(cols) != 2 {
fmt.Println("Expected column not found")
}
Reference :
Advertisement
Something interesting
Tutorials
+14.9k Golang : How to check for empty array string or string?
+10.5k Swift : Convert (cast) String to Integer
+9.8k Golang : Resumable upload to Google Drive(RESTful) example
+22.9k Golang : Gorilla mux routing example
+7.4k Golang : Scanf function weird error in Windows
+7.2k Golang : Check if one string(rune) is permutation of another string(rune)
+10.2k Golang : Random Rune generator
+5.7k List of Golang XML tutorials
+4.6k Linux : sudo yum updates not working
+14.2k Golang : Chunk split or divide a string into smaller chunk example
+8.9k Golang : Sort lines of text example