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
+8.8k Golang : Gorilla web tool kit schema example
+10.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+10.1k Golang : Compare files modify date example
+8.7k Golang : Find duplicate files with filepath.Walk
+6.9k How to let Facebook Login button redirect to a particular URL ?
+13.5k Golang : Count number of runes in string
+11.9k Golang : Convert(cast) bigint to string
+5.8k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag
+26.6k Golang : Encrypt and decrypt data with AES crypto
+24.5k Golang : Time slice or date sort and reverse sort example
+16.9k Golang : Set up source IP address before making HTTP request