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
+13.9k Golang : Get dimension(width and height) of image file
+10.3k Golang : Wait and sync.WaitGroup example
+7.4k Golang : Individual and total number of words counter example
+20.3k Swift : Convert (cast) Int to int32 or Uint32
+8k Golang : Sort words with first uppercase letter
+10.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+5.7k List of Golang XML tutorials
+6.5k Golang : Handling image beyond OpenCV video capture boundary
+7.9k Golang : Trim everything onward after a word
+18.7k Golang : convert int to string
+11.5k Use systeminfo to find out installed Windows Hotfix(s) or updates