A zero dependency library to handle SQL nullable values.
- You can use the below command to install
null.
$ go get -u github.com/mobyfox/null- Import it in your code
import "github.com/mobyfox/null"Nullable bool.
Marshals to JSON null if data coming from SQL is null. False will not produce a null Bool.
type Example struct {
Bool null.Bool `json:"bool"`
}Nullable byte.
Marshals to JSON null if data coming from SQL is null. Blank input will not produce a null Byte.
type Example struct {
Byte null.Byte `json:"byte"`
}Nullable float64.
Marshals to JSON null if data coming from SQL is null. Zero input will not produce a null Float64.
type Example struct {
Float64 null.Float64 `json:"float64"`
}Nullable int16.
Marshals to JSON null if data coming from SQL is null. Zero input will not produce a null Int16.
type Example struct {
Int16 null.Int16 `json:"int16"`
}Nullable int32.
Marshals to JSON null if data coming from SQL is null. Zero input will not produce a null Int32.
type Example struct {
Int32 null.Int32 `json:"int32"`
}Nullable int64.
Marshals to JSON null if data coming from SQL is null. Zero input will not produce a null Int64.
type Example struct {
Int64 null.Int64 `json:"int64"`
}Nullable string.
Marshals to JSON null if data coming from SQL is null. Blank input will not produce a null String.
type Example struct {
String null.String `json:"string"`
}Nullable time.
Marshals to JSON null if data coming from SQL is null. Blank input will not produce a null Time.
type Example struct {
Time null.Time `json:"time"`
}This project utilizes the Apache License 2.0 please do read the permissions, conditions and limitations before using this library.