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
+11.7k Golang : Gorilla web tool kit secure cookie example
+4k Detect if Google Analytics and Developer Media are loaded properly or not
+5.2k Golang : PGX CopyFrom to insert rows into Postgres database
+20.9k Golang : Convert PNG transparent background image to JPG or JPEG image
+7.5k Gogland : Single File versus Go Application Run Configurations
+19.2k Golang : Execute shell command
+11.3k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+18.4k Golang : Logging with logrus
+11.6k Golang : Convert(cast) float to int
+4.1k Javascript : Empty an array example
+25.3k Golang : Convert uint value to string type
+10.8k PHP : Convert(cast) bigInt to string