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
+7.2k CloudFlare : Another way to get visitor's real IP address
+5.6k Fix fatal error: evacuation not done in time problem
+22.7k Golang : Round float to precision example
+13.5k Facebook PHP getUser() returns 0
+55.3k Golang : Unmarshal JSON from http response
+20.2k Golang : Compare floating-point numbers
+19.9k Golang : How to get time from unix nano example
+7.3k Golang : How to convert strange string to JSON with json.MarshalIndent
+17k Golang : How to save log messages to file?
+12.4k Elastic Search : Return all records (higher than default 10)
+13.1k Golang : List objects in AWS S3 bucket
+10.2k Golang : Text file editor (accept input from screen and save to file)