Golang database/sql.NullInt64 type examples
package database/sql
NullInt64 represents an int64 that may be null. NullInt64 implements the Scanner interface so it can be used as a scan destination, similar to NullString.
Golang database/sql.NullInt64 type usage examples
Example 1:
var ni64 = sql.NullInt64{Valid: true}
Example 2:
// NullInt64
var ni sql.NullInt64
// Invalid
if err = nullStmt.QueryRow().Scan(&ni); err != nil {
dbt.Fatal(err)
}
if ni.Valid {
dbt.Error("Valid NullInt64 which should be invalid")
}
References :
https://github.com/go-sql-driver/mysql/blob/master/driver_test.go
Advertisement
Something interesting
Tutorials
+3.4k Golang : Fix go-cron set time not working issue
+22.4k Golang : How to read JPG(JPEG), GIF and PNG files ?
+17k Golang : Get input from keyboard
+10.8k Golang : Natural string sorting example
+8.9k Golang : Find network service name from given port and protocol
+7.3k Golang : How to fix html/template : "somefile" is undefined error?
+13.2k Golang : How to calculate the distance between two coordinates using Haversine formula
+15.6k Golang : ROT47 (Caesar cipher by 47 characters) example
+19k Golang : Padding data for encryption and un-padding data for decryption
+30.9k Golang : Interpolating or substituting variables in string examples
+5.7k List of Golang XML tutorials
+8.3k Golang : Number guessing game with user input verification example