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
+9.1k Golang : Intercept and compare HTTP response code example
+10.6k Golang : Simple File Server
+13.2k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+14.6k Golang : Execute function at intervals or after some delay
+8.1k Golang : Check from web if Go application is running or not
+15.3k Golang : How to get Unix file descriptor for console and file
+20.8k Golang : Convert date string to variants of time.Time type examples
+23.7k Find and replace a character in a string in Go
+25k Golang : Create PDF file from HTML file
+14.3k Golang : Get uploaded file name or access uploaded files
+7.1k Golang : Gorrila mux.Vars() function example
+13.5k Facebook PHP getUser() returns 0