Golang database/sql.Rows.Err function examples
package database/sql
Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.
Golang database/sql.Rows.Err function usage examples
Example 1:
r, err := db.Query("SELECT 1")
if err != nil {
t.Fatal(err)
}
err = r.Close()
if err != nil {
t.Fatal(err)
}
if r.Next() {
t.Fatal("unexpected row")
}
if r.Err() != nil { // <----- here
t.Fatal(r.Err())
}
Example 2:
if err = rows.Err(); err != nil {
fmt.Println(err)
os.Exit(1)
}
Reference :
Advertisement
Something interesting
Tutorials
+13k Golang : Calculate elapsed years or months since a date
+5k Python : Convert(cast) bytes to string example
+21.2k Golang : How to force compile or remove object files first before rebuild?
+17.2k Golang : Find file size(disk usage) with filepath.Walk
+14.1k Golang : Check if a file exist or not
+17k Golang : Get input from keyboard
+14.5k Golang : How to check if your program is running in a terminal
+17.7k Golang : Read data from config file and assign to variables
+36.7k Golang : Display float in 2 decimal points and rounding up or down
+9.9k Golang : Sort and reverse sort a slice of integers
+12.3k Golang : List running EC2 instances and descriptions
+19.2k Golang : Check whether a network interface is up on your machine