Documentation ¶
Overview ¶
Package null contains types that consider zero input and null input as separate values. Types in this package will always encode to their null value if null. Use the zero subpackage if you want empty and null to be treated the same.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
Bool is an even nuller nullable bool. It does not consider false values to be null. It will decode to null, not false, if null.
func BoolFromPtr ¶
BoolFromPtr creates a new Bool that will be null if f is nil.
func (Bool) IsZero ¶
IsZero returns true for invalid Bools, for future omitempty support (Go 1.4?) A non-null Bool with a 0 value will not be considered zero.
func (Bool) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Bool is null.
func (Bool) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Bool is null.
func (Bool) Ptr ¶
Ptr returns a pointer to this Bool's value, or a nil pointer if this Bool is null.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Bool. It also supports unmarshalling a sql.NullBool.
func (*Bool) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Bool if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or "null".
type Float ¶
type Float struct {
sql.NullFloat64
}
Float is an even nuller nullable float64. It does not consider zero values to be null. It will decode to null, not zero, if null.
func FloatFromPtr ¶
FloatFromPtr creates a new Float that be null if f is nil.
func (Float) IsZero ¶
IsZero returns true for invalid Floats, for future omitempty support (Go 1.4?) A non-null Float with a 0 value will not be considered zero.
func (Float) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Float is null.
func (Float) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Float is null.
func (Float) Ptr ¶
Ptr returns a pointer to this Float's value, or a nil pointer if this Float is null.
func (*Float) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Float. It also supports unmarshalling a sql.NullFloat64.
func (*Float) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Float if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or "null".
type Int ¶
Int is an even nuller nullable int64. It does not consider zero values to be null. It will decode to null, not zero, if null.
func IntFromPtr ¶
IntFromPtr creates a new Int that be null if i is nil.
func (Int) IsZero ¶
IsZero returns true for invalid Ints, for future omitempty support (Go 1.4?) A non-null Int with a 0 value will not be considered zero.
func (Int) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Int is null.
func (Int) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Int is null.
func (*Int) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Int. It also supports unmarshalling a sql.NullInt64.
func (*Int) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or "null".
type String ¶
type String struct {
sql.NullString
}
String is an even nuller nullable string.
func StringFrom ¶
StringFrom creates a new String that will never be blank.
func StringFromPtr ¶
StringFromPtr creates a new String that be null if s is nil.
func (String) IsZero ¶
IsZero returns true for null or empty strings, for future omitempty support. (Go 1.4?) Will return false s if blank but non-null.
func (String) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this String is null.
func (String) Ptr ¶
Ptr returns a pointer to this String's value, or a nil pointer if this String is null.
func (*String) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input produces a null String. It also supports unmarshalling a sql.NullString.
func (*String) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null String if the input is a blank string.