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
+11.1k Golang : How to determine a prime number?
+20.8k Golang : Underscore or snake_case to camel case example
+12.4k Golang : Encrypt and decrypt data with x509 crypto
+12.9k Python : Convert IPv6 address to decimal and back to IPv6
+37.7k Golang : Comparing date or timestamp
+35.5k Golang : Smarter Error Handling with strings.Contains()
+10.9k Golang : Create Temporary File
+30k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+17.6k Golang : Parse date string and convert to dd-mm-yyyy format
+9.3k Golang : Generate random Chinese, Japanese, Korean and other runes
+11.3k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+5k Python : Convert(cast) bytes to string example