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
+8.1k Golang : Variadic function arguments sanity check example
+25.3k Golang : Convert uint value to string type
+9k Golang : Inject/embed Javascript before sending out to browser example
+20.2k Golang : How to get struct tag and use field name to retrieve data?
+4.7k Golang : How to pass data between controllers with JSON Web Token
+9k Golang : Go as a script or running go with shebang/hashbang style
+7.6k SSL : How to check if current certificate is sha1 or sha2 from command line
+11.6k Golang : Simple file scaning and remove virus example
+30.8k Golang : Download file example
+20.5k Golang : Pipe output from one os.Exec(shell command) to another command
+12.3k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+9.4k Golang : Create unique title slugs example