Golang database/sql.Row type and Scan function example
package database/sql
Row is the result of calling QueryRow to select a single row.
Scan copies the columns from the matched row into the values pointed at by dest. If more than one row matches the query, Scan uses the first row and discards the rest. If no row matches the query, Scan returns ErrNoRows.
Golang database/sql.Row type usage example
var username string
err = db.QueryRow("select username from accounts where id = ?", 1).Scan(&username)
if err != nil {
log.Fatal(err)
}
fmt.Println(name)
References :
Advertisement
Something interesting
Tutorials
+7.3k Golang : Of hash table and hash map
+13k Golang : Calculate elapsed years or months since a date
+5.4k Golang : Get S3 or CloudFront object or file information
+7.3k Golang : alternative to os.Exit() function
+26.9k Golang : Force your program to run with root permissions
+11.6k Golang : Surveillance with web camera and OpenCV
+8.5k Linux/Unix : fatal: the Postfix mail system is already running
+7.3k Golang : Not able to grep log.Println() output
+23.9k Golang : Fix type interface{} has no field or no methods and type assertions example
+8.5k PHP : How to parse ElasticSearch JSON ?
+7.1k Golang : Squaring elements in array