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
+8.1k Golang : Multiplexer with net/http and map
+9.3k Golang : How to get ECDSA curve and parameters data?
+6.1k Golang : How to write backslash in string?
+16.3k Golang :Trim white spaces from a string
+46.5k Golang : Marshal and unmarshal json.RawMessage struct example
+10.4k Golang : cannot assign type int to value (type uint8) in range error
+4.7k Adding Skype actions such as call and chat into web page examples
+10k Golang : Setting variable value with ldflags
+7.4k Android Studio : How to detect camera, activate and capture example
+3.7k Golang : Switch Redis database redis.NewClient
+5.1k Golang : Check if a word is countable or not
+5.6k PHP : Convert CSV to JSON with YQL example