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.2k Golang : Calculate Relative Strength Index(RSI) example
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+7.4k Golang : Accessing dataframe-go element by row, column and name example
+24k Golang : Find biggest/largest number in array
+7.9k Golang : Trim everything onward after a word
+14.4k Golang : How to filter a map's elements for faster lookup
+6k Golang : Function as an argument type example
+48.5k Golang : Upload file from web browser to server
+8.2k Golang : HttpRouter multiplexer routing example
+3.6k Java : Get FX sentiment from website example
+8.8k Yum Error: no such table: packages
+8.6k Golang : Progress bar with ∎ character