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
+5.7k Fix yum-complete-transaction error
+5.8k Unix/Linux : How to test user agents blocked successfully ?
+6.2k PHP : Get client IP address
+14.4k Android Studio : Use image as AlertDialog title with custom layout example
+8.2k Golang : Add build version and other information in executables
+5.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+17.6k Golang : Upload/Receive file progress indicator
+7.2k Golang : Null and nil value
+8.3k Swift : Convert (cast) Character to Integer?
+8.3k Golang : Configure Apache and NGINX to access your Go service example
+5.3k Javascript : Change page title to get viewer attention
+8.2k Golang : HttpRouter multiplexer routing example