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
+11.3k Golang : Post data with url.Values{}
+5.5k Golang : Display advertisement images or strings on random order
+25.4k Golang : Convert long hexadecimal with strconv.ParseUint example
+19.5k Golang : Example for DSA(Digital Signature Algorithm) package functions
+8.2k Golang : Find relative luminance or color brightness
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+5.1k Linux/Unix/MacOSX : Find out which application is listening to port 80 or use which IP version
+15.8k Golang : How to login and logout with JWT example
+23.5k Golang : Check if element exist in map
+6.3k Golang : Selection sort example
+20.2k Golang : Count number of digits from given integer value
+14.6k Golang : How to get URL port?