Documentation ¶
Overview ¶
Package null contains SQL types that consider zero input and null input as separate values, with convenient support for JSON and text marshaling. Types in this package will always encode to their null value if null. Use the zero subpackage if you want zero values and null to be treated the same.
Index ¶
- func IsEmptyString(n String) bool
- type Bool
- func (b Bool) GetBSON() (interface{}, error)
- func (b Bool) GetValue() reflect.Value
- func (b Bool) IsZero() bool
- func (b *Bool) LoremDecode(tag, example string) error
- func (b Bool) MarshalJSON() ([]byte, error)
- func (b Bool) MarshalText() ([]byte, error)
- func (b Bool) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (b Bool) Ptr() *bool
- func (b *Bool) SetBSON(raw bson.Raw) error
- func (b *Bool) SetValid(v bool)
- func (b *Bool) UnmarshalJSON(data []byte) error
- func (b *Bool) UnmarshalText(text []byte) error
- func (b *Bool) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- type Float
- func (f Float) GetBSON() (interface{}, error)
- func (f Float) GetValue() reflect.Value
- func (f Float) IsZero() bool
- func (f *Float) LoremDecode(tag, example string) error
- func (f Float) MarshalJSON() ([]byte, error)
- func (f Float) MarshalText() ([]byte, error)
- func (f Float) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (f Float) Ptr() *float64
- func (f *Float) SetBSON(raw bson.Raw) error
- func (f *Float) SetValid(n float64)
- func (f *Float) UnmarshalJSON(data []byte) error
- func (f *Float) UnmarshalText(text []byte) error
- func (f *Float) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- type Int32
- func (i Int32) GetBSON() (interface{}, error)
- func (i Int32) GetValue() reflect.Value
- func (i Int32) IsZero() bool
- func (i *Int32) LoremDecode(tag, example string) error
- func (i Int32) MarshalJSON() ([]byte, error)
- func (i Int32) MarshalText() ([]byte, error)
- func (i Int32) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (i Int32) Ptr() *int32
- func (i *Int32) SetBSON(raw bson.Raw) error
- func (i *Int32) SetValid(n int32)
- func (i *Int32) UnmarshalJSON(data []byte) error
- func (i *Int32) UnmarshalText(text []byte) error
- func (i *Int32) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- type Int64
- func (i Int64) GetBSON() (interface{}, error)
- func (i Int64) GetValue() reflect.Value
- func (i Int64) IsZero() bool
- func (i *Int64) LoremDecode(tag, example string) error
- func (i Int64) MarshalJSON() ([]byte, error)
- func (i Int64) MarshalText() ([]byte, error)
- func (i Int64) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (i Int64) Ptr() *int64
- func (i *Int64) SetBSON(raw bson.Raw) error
- func (i *Int64) SetValid(n int64)
- func (i *Int64) UnmarshalJSON(data []byte) error
- func (i *Int64) UnmarshalText(text []byte) error
- func (i *Int64) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- type String
- func (s String) GetBSON() (interface{}, error)
- func (s String) GetValue() reflect.Value
- func (s String) IsZero() bool
- func (s *String) LoremDecode(tag, example string) error
- func (s String) MarshalJSON() ([]byte, error)
- func (s String) MarshalText() ([]byte, error)
- func (s String) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (s String) Ptr() *string
- func (s *String) SetBSON(raw bson.Raw) error
- func (s *String) SetValid(v string)
- func (s *String) UnmarshalJSON(data []byte) error
- func (s *String) UnmarshalText(text []byte) error
- func (s *String) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- type Time
- func (t Time) AppendValue(b []byte, quote int) ([]byte, error)
- func (t Time) GetBSON() (interface{}, error)
- func (t Time) GetValue() reflect.Value
- func (t Time) IsZero() bool
- func (t *Time) LoremDecode(tag, example string) error
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) MarshalText() ([]byte, error)
- func (t Time) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (t Time) Ptr() *time.Time
- func (t *Time) Scan(value interface{}) error
- func (t *Time) SetBSON(raw bson.Raw) error
- func (t *Time) SetValid(v time.Time)
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t *Time) UnmarshalText(text []byte) error
- func (t *Time) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (t Time) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEmptyString ¶
IsEmptyString useful for when the value needs to be check for zero
Types ¶
type Bool ¶
Bool is a 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) LoremDecode ¶
LoremDecode implements lorem.Decoder
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) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface
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".
func (*Bool) UnmarshalXML ¶
UnmarshalXML implments the xml.Unmarshaler interface
type Float ¶
type Float struct {
sql.NullFloat64
}
Float is a 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) LoremDecode ¶
LoremDecode implements lorem.Decoder
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) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface
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".
func (*Float) UnmarshalXML ¶
UnmarshalXML implments the xml.Unmarshaler interface
type Int32 ¶
Int32 is an nullable int32. It does not consider zero values to be null. It will decode to null, not zero, if null.
func Int32FromPtr ¶
Int32FromPtr creates a new Int32 that be null if i is nil.
func (Int32) IsZero ¶
IsZero returns true for invalid Ints, for future omitempty support (Go 1.4?) A non-null Int32 with a 0 value will not be considered zero.
func (*Int32) LoremDecode ¶
LoremDecode implements lorem.Decoder
func (Int32) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Int32 is null.
func (Int32) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Int32 is null.
func (Int32) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface
func (Int32) Ptr ¶
Ptr returns a pointer to this Int32's value, or a nil pointer if this Int32 is null.
func (*Int32) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Int32. It also supports unmarshalling a sql.NullInt32.
func (*Int32) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int32 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".
func (*Int32) UnmarshalXML ¶
UnmarshalXML implments the xml.Unmarshaler interface
type Int64 ¶
Int64 is an nullable int64. It does not consider zero values to be null. It will decode to null, not zero, if null.
func Int64FromPtr ¶
Int64FromPtr creates a new Int64 that be null if i is nil.
func (Int64) IsZero ¶
IsZero returns true for invalid Ints, for future omitempty support (Go 1.4?) A non-null Int64 with a 0 value will not be considered zero.
func (*Int64) LoremDecode ¶
LoremDecode implements lorem.Decoder
func (Int64) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Int64 is null.
func (Int64) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Int64 is null.
func (Int64) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface
func (Int64) Ptr ¶
Ptr returns a pointer to this Int64's value, or a nil pointer if this Int64 is null.
func (*Int64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Int64. It also supports unmarshalling a sql.NullInt64.
func (*Int64) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int64 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".
func (*Int64) UnmarshalXML ¶
UnmarshalXML implments the xml.Unmarshaler interface
type String ¶
type String struct {
sql.NullString
}
String is a nullable string. It supports SQL and JSON serialization. It will marshal to null if null. Blank string input will be considered null.
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 strings, for potential future omitempty support.
func (*String) LoremDecode ¶
LoremDecode implements lorem.Decoder
func (String) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this String is null.
func (String) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string when this String is null.
func (String) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface
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 does not produce 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.
func (*String) UnmarshalXML ¶
UnmarshalXML implments the xml.Unmarshaler interface
type Time ¶
Time is a nullable time.Time. It supports SQL and JSON serialization. It will marshal to null if null.
func TimeFromPtr ¶
TimeFromPtr creates a new Time that will be null if t is nil.
func (Time) AppendValue ¶
AppendValue implements the types.ValueAppender interface
func (*Time) LoremDecode ¶
LoremDecode implements lorem.Decoder
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this time is null.
func (Time) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (Time) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface
func (Time) Ptr ¶
Ptr returns a pointer to this Time's value, or a nil pointer if this Time is null.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string, object (e.g. pq.NullTime and friends) and null input.
func (*Time) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (*Time) UnmarshalXML ¶
UnmarshalXML implments the xml.Unmarshaler interface
Directories ¶
Path | Synopsis |
---|---|
Package zero contains SQL types that consider zero input and null input to be equivalent with convenient support for JSON and text marshaling.
|
Package zero contains SQL types that consider zero input and null input to be equivalent with convenient support for JSON and text marshaling. |