Documentation ¶
Overview ¶
Package null defines a number of nullable types that bridge the packages database/sql, encoding, encoding/json, and encoding/maps. Many are simple wrappers around atabase/sql types (sql.NullString, sql.NullInt64, etc.), but all implement all of the following interfaces,
- IsNiler from pyrrho/encoding -- IsNil() bool
- IsZeroer from pyrrho/encoding -- IsZero() bool
- Valuer from database/sql/driver -- Value() (driver.Value, error)
- Scanner from database/sql -- Scan(src interface{}) error
- Marshaler from encoding/json -- MarshalJSON() ([]byte, error)
- Unmarshaler from encoding/json -- UnmarshalJSON(data []byte) error
- Marshaler from pyrrho/encoding/maps -- MarshalMap() (map[string]interface{}, error)
- Unmarshaler from pyrrho/encoding/maps -- [Pending maps.Unmarshal features]
Index ¶
- type Bool
- type ByteSlice
- func (b ByteSlice) IsNil() bool
- func (b ByteSlice) IsZero() bool
- func (b ByteSlice) MarshalJSON() ([]byte, error)
- func (b ByteSlice) MarshalMapValue() (interface{}, error)
- func (b *ByteSlice) Null()
- func (b *ByteSlice) Scan(src interface{}) error
- func (b *ByteSlice) Set(v []byte)
- func (b *ByteSlice) SetStr(v string)
- func (b *ByteSlice) UnmarshalJSON(data []byte) error
- func (b ByteSlice) Value() (driver.Value, error)
- func (b ByteSlice) ValueOrZero() []byte
- type Float64
- func (f Float64) IsNil() bool
- func (f Float64) IsZero() bool
- func (f Float64) MarshalJSON() ([]byte, error)
- func (f Float64) MarshalMapValue() (interface{}, error)
- func (f *Float64) Null()
- func (f *Float64) Set(v float64)
- func (f *Float64) UnmarshalJSON(data []byte) error
- func (f Float64) ValueOrZero() float64
- type Int64
- type RawJSON
- func (j RawJSON) IsNil() bool
- func (j RawJSON) IsZero() bool
- func (j RawJSON) MarshalJSON() ([]byte, error)
- func (j RawJSON) MarshalMapValue() (interface{}, error)
- func (j *RawJSON) Null()
- func (j *RawJSON) Scan(src interface{}) error
- func (j *RawJSON) Set(v types.RawJSON)
- func (j *RawJSON) SetStr(v string)
- func (j *RawJSON) UnmarshalJSON(data []byte) error
- func (j RawJSON) Value() (driver.Value, error)
- func (j RawJSON) ValueOrZero() types.RawJSON
- type SFPoint
- func (p SFPoint) IsNil() bool
- func (p SFPoint) IsZero() bool
- func (p SFPoint) MarshalJSON() ([]byte, error)
- func (p SFPoint) MarshalMapValue() (interface{}, error)
- func (p *SFPoint) Null()
- func (p *SFPoint) Scan(src interface{}) error
- func (p *SFPoint) Set(v types.SFPoint)
- func (p *SFPoint) UnmarshalJSON(data []byte) error
- func (p SFPoint) Value() (driver.Value, error)
- func (p SFPoint) ValueOrZero() types.SFPoint
- type SFPolygon
- func (p SFPolygon) IsNil() bool
- func (p SFPolygon) IsZero() bool
- func (p SFPolygon) MarshalJSON() ([]byte, error)
- func (p SFPolygon) MarshalMapValue() (interface{}, error)
- func (p *SFPolygon) Null()
- func (p *SFPolygon) Scan(src interface{}) error
- func (p *SFPolygon) Set(v types.SFPolygon)
- func (p *SFPolygon) UnmarshalJSON(data []byte) error
- func (p SFPolygon) Value() (driver.Value, error)
- func (p SFPolygon) ValueOrZero() types.SFPolygon
- type String
- func (s String) IsNil() bool
- func (s String) IsZero() bool
- func (s String) MarshalJSON() ([]byte, error)
- func (s String) MarshalMapValue() (interface{}, error)
- func (s *String) Null()
- func (s *String) Set(v string)
- func (s *String) UnmarshalJSON(data []byte) error
- func (s String) ValueOrZero() string
- type Time
- func (t Time) IsNil() bool
- func (t Time) IsZero() bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) MarshalMapValue() (interface{}, error)
- func (t *Time) Null()
- func (t *Time) Scan(src interface{}) error
- func (t *Time) Set(v time.Time)
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t Time) Value() (driver.Value, error)
- func (t Time) ValueOrZero() time.Time
- type Uint8
- func (i Uint8) IsNil() bool
- func (i Uint8) IsZero() bool
- func (i Uint8) MarshalJSON() ([]byte, error)
- func (i Uint8) MarshalMapValue() (interface{}, error)
- func (i *Uint8) Null()
- func (i *Uint8) Scan(src interface{}) error
- func (i *Uint8) Set(v uint8)
- func (i *Uint8) UnmarshalJSON(data []byte) error
- func (i Uint8) Value() (driver.Value, error)
- func (i Uint8) ValueOrZero() uint8
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
Bool is a wrapper around the database/sql NullBool type that implements all of the pyrrho/encoding/types interfaces detailed in the package comments that sql.NullBool doesn't implement out of the box.
If the Bool is valid and contains false, it will be considered non-nil, and of zero value.
func NewBool ¶
NewBool constructs and returns a new, valid Bool initialized with the value of the given b.
func (Bool) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if b is null.
func (Bool) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if b is null or if its value is false.
func (Bool) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will encode b into its JSON representation if valid, or 'null' otherwise.
func (Bool) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode b into its interface{} representation for use in a map[string]interface{} if valid, or return nil otherwise.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It will decode a given []byte into b, so long as the provided []byte is a valid jSON representation of a bool or a null.
The keyword 'null' will result in a null NullBool. The keywords 'true' and 'false' will result in a valid NullBool containing the value you would expect. The strings '"true"', '"false"', '"null"', and `""` are considered to be strings -- not keywords -- and will result in an error.
If the decode fails, the value of b will be unchanged.
func (Bool) ValueOrZero ¶
ValueOrZero returns the value of b if it is valid; otherwise, it returns the zero value for a bool (false).
type ByteSlice ¶
ByteSlice is a nullable wrapper around the []byte type. It implements all of the pyrrho/encoding/types interfaces detailed in the package comments. This type makes a distinction between nil and valid-but-empty []bytes. It is valid to initialzed a ByteSlice with an empty []byte{}, but it is not valid to initialize a ByteSlice with a []byte(nil). This distinction holds true for the Set, Scan, an Unmarshal function groups.
To maintain consistency with the encoding/json package -- and to ensure we never attempt to marshal non-ASCII characters -- this type will emit base64 encoded strings from MarshalJSON, Value, and MarshalMapValue (when non-null), and expect to receive base64 encoded strings in UnmarshalJSON and Scan.
func NewByteSlice ¶
NewByteSlice constructs and returns a new ByteSlice based on the given []byte b. If b is of zero length the new ByteSlice will be null. Otherwise a new, valid ByteSlice will be initialized with a copy of b.
func NewByteSliceFromBase64 ¶
NewByteSliceFromBase64 constructs and returns a new ByteSlice object based on the given base64 encoded []byte b.
func NewByteSliceFromBase64Str ¶
NewByteSliceFromBase64Str constructs and returns a new ByteSlice object based on the given base64 encoded []byte b.
func NewByteSliceStr ¶
NewByteSliceStr constructs and returns a new ByteSlice object based on the given string s. If s is the empty string, the new ByteSlice will be null. Otherwise s will be cast to []byte and used to initialize the new, valid ByteSlice.
func NullByteSlice ¶
func NullByteSlice() ByteSlice
NullByteSlice constructs and returns a new null ByteSlice.
func (ByteSlice) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if b is null.
func (ByteSlice) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if b is null or if its value is false.
func (ByteSlice) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will encode b into its base64 representation if valid, or 'null' otherwise.
func (ByteSlice) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode b into its base64 encoded interface{} representation for use in a map[string]interface{} if valid, or return nil otherwise.
func (*ByteSlice) Scan ¶
Scan implements the database/sql Scanner interface. It will receive a value from an SQL database and assign it to b, so long as the provided data can be is a []byte, a string, or nil. Valid data is expected to be base64 encoded.
func (*ByteSlice) Set ¶
Set copies the given []byte v into b. If v is of length zero, b will be nulled.
func (*ByteSlice) SetStr ¶
SetStr copies the given string v into b. If v is of length zero, b will be nulled.
func (*ByteSlice) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It will decode a given []byte into b, so long as the provided []byte is a valid base64 encoded string or a null.
An empty string will result in a valid-but-empty ByteSlice. The keyword 'null' will result in a null ByteSlice. The string '"null"' is considered to be a string -- not a keyword -- and will result in base64 decoded garbage.
If the decode fails, the value of b will be unchanged.
func (ByteSlice) Value ¶
Value implements the database/sql/driver Valuer interface. It will base64 encode valid values prior to returning them.
func (ByteSlice) ValueOrZero ¶
ValueOrZero returns the value of b if it is valid; otherwise,it returns an empty []byte.
type Float64 ¶
type Float64 struct {
sql.NullFloat64
}
Float64 is a wrapper around the database/sql NullFloat64 type that implements all of the pyrrho/encoding/types interfaces detailed in the package comments that sql.NullFloat64 doesn't implement out of the box.
If the Float64 is valid and contains 0, it will be considered non-nil, and of zero value.
func NewFloat64 ¶
NewFloat64 constructs and returns a new, valid Float64 initialized with the value of the given f.
func NullFloat64 ¶
func NullFloat64() Float64
NullFloat64 constructs and returns a new null Float64.
func (Float64) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if f is null.
func (Float64) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if f is null or if its value is 0.
func (Float64) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will attempt to encode f into its JSON representation if valid. If the contained value is +/-INF or NaN, a json.UnsupportedValueError will be returned. If f is not valid, it will encode to 'null'.
func (Float64) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode f into its interface{} representation for use in a map[string]interface{} if valid, or return nil otherwise.
func (*Float64) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It will decode a given []byte into f, so long as the provided []byte is a valid JSON representation of a float or null. The 'null' keyword will decode into a null Float64.
If the decode fails, the value of f will be unchanged.
func (Float64) ValueOrZero ¶
ValueOrZero returns the value of f if it is valid; otherwise it returns the zero value for a float64 (0.0).
type Int64 ¶
Int64 is a wrapper around the database/sql NullInt64 type that implements all of the pyrrho/encoding/types interfaces detailed in the package comments that sql.NullInt64 doesn't implement out of the box.
If the Int64 is valid and contains 0, it will be considered non-nil, and of zero value.
func NewInt64 ¶
NewInt64 constructs and returns a new, valid Int64 initialized with the value of the given i.
func (Int64) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if i is null.
func (Int64) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if i is null or if its value is 0.
func (Int64) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will encode i into its JSON representation if valid, or 'null' otherwise.
func (Int64) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode i into its interface{} representation for use in a map[string]interface{} if valid, or return nil otherwise.
func (*Int64) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It will decode a given []byte into i, so long as the provided []byte is a valid JSON representation of an int. The 'null' keyword will decode into a null Int64.
If the decode fails, the value of i will be unchanged.
func (Int64) ValueOrZero ¶
ValueOrZero returns the value of i if it is valid; otherwise it returns the zero value for a int64 (0).
type RawJSON ¶
RawJSON is a wrapper around types.RawJSON that makes the type null-aware, in terms of both the JSON 'null' keyword, and SQL NULL values. It implements all of the pyrrho/encoding/types interfaces detailed in the package comments.
func NewJSON ¶
NewJSON constructs and returns a new RawJSON object based on the given types.RawJSON j. If j is of zero-length the new RawJSON will be null. Otherwise a new, valid RawJSON will be initialized with a copy of j.
func NewJSONStr ¶
NewJSONStr constructs and returns a new RawJSON object based on the given string s. If s is the empty string, the new RawJSON will be null. Otherwise s will be cast to types.RawJSON and used to initialize the new valid RawJSON.
func (RawJSON) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if j is null.
func (RawJSON) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if j is null or if the contained JSON is a zero value.
func (RawJSON) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will return the value of j as a JSON-encoded []byte. If j is valid, this function will first validate the contained JSON returning either any encouted parsing errors, or a []byte. If j is null, "null" will be returned, and no validation will occur.
func (RawJSON) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode j into its interface{} representation for use in a map[string]interface{} by passing it through JSON.Unmarshal if valid, or the 'null' keyword otherwise.
func (*RawJSON) Null ¶
func (j *RawJSON) Null()
Null will set j to null; j.Valid will be false, and j.JSON will contain no meaningful value.
func (*RawJSON) Scan ¶
Scan implements the database/sql Scanner interface. It expects to receive a valid JSON value as a string or a []byte, or NULL as a nil from an SQL database. A zero-length string or []byte, or a nil will be considered NULL, and j will be nulled, otherwise the the value will be assigned to j. Scan will not validate the incoming JSON.
func (*RawJSON) Set ¶
Set copies the given types.RawJSON value into j. If the given value is of length 0, j will be nulled.
func (*RawJSON) SetStr ¶
SetStr will copy the contents of v into j. If the given value is an empty string, j will be nulled.
func (*RawJSON) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It expects to receive a valid JSON value, and will assign that value to this RawJSON. If the incoming JSON is the 'null' keyword, j will be nulled. UnmarshalJSON will validate the incoming JSON as part of the "Is this JSON null?" check.
func (RawJSON) Value ¶
Value implements the database/sql/driver Valuer interface. It will return the value of j as a driver.Value. If j is valid, this function will first validate the contained JSON returning either any encouted parsing errors, or a []byte as a driver.Value. If j is null, nil will be returned, and no validation will occur.
func (RawJSON) ValueOrZero ¶
ValueOrZero will return the value of j if it is valid, or a newly constructed zero-value types.RawJSON otherwise.
type SFPoint ¶
SFPoint is a wrapper around types.SFPoint that makes the type null-aware, in terms of both the JSON 'null' keyword, and SQL NULL values. It implements all of the pyrrho/encoding/types interfaces detailed in the package comments.
func NewSFPoint ¶
NewSFPoint constructs and returns a new SFPoint object based on the given types.SFPoint p. If p is nil, the new SFPoint will be null. Otherwise a new, valid SFPoint will be initialized with a copy of p.
func NewSFPointXY ¶
NewSFPointXY constructs and returns a new SFPoint object based on the given longitude and latitude coordinates.
func NewSFPointXYZ ¶
NewSFPointXY constructs and returns a new SFPoint object based on the given longitude, latitude, and altitude coordinates.
func NullSFPoint ¶
func NullSFPoint() SFPoint
NullSFPoint constructs and returns a new null SFPoint object.
func (SFPoint) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if p is null.
func (SFPoint) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if p is null or if the contained SFPoint is a zero value.
func (SFPoint) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will return the GeoJSON encoded representation of p, or "null" if p is null.
func (SFPoint) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode p into its interface{} representation for use in a map[string]interface{} by passing it through JSON.Unmarshal if valid, or the 'null' keyword otherwise.
func (*SFPoint) Null ¶
func (p *SFPoint) Null()
Null will set p to null; p.Valid will be false, and p.Point will contain no meaningful value.
func (*SFPoint) Scan ¶
Scan implements the database/sql Scanner interface. It expects to receive a valid WKB encoded []byte describing a Point, or NULL as a nil from an SQL database. A zero-length or nil []byte will be considered NULL, and p will be nulled. Otherwise, the value will be passed to types.SFPoint to be scanned and parsed as a WKB Point.
func (*SFPoint) Set ¶
Set copies the given types.SFPoint value into p. If the given value is nil, p will be nulled.
func (*SFPoint) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It expects to receive a valid GeoJSON Geometry of the type Point, and will assign the value of that data to p. If the incoming JSON is the 'null' keyword, p will have no valid value.
func (SFPoint) Value ¶
Value implements the database/sql/driver Valuer interface. It will return the value of p as a driver.Value. If p is null, nil will be returned.
func (SFPoint) ValueOrZero ¶
ValueOrZero will return the value of p if it is valid, or a newly constructed zero-value types.SFPoint otherwise.
type SFPolygon ¶
SFPolygon is a wrapper around types.SFPolygon that makes the type null-aware, in terms of both the JSON 'null' keyword, and SQL NULL values. It implements all of the pyrrho/encoding/types interfaces detailed in the package comments.
func NewSFPolygon ¶
NewSFPolygon constructs and returns a new SFPolygon object based on the given types.SFPolygon p. If p is nil, the new SFPolygon will be null. Otherwise a new, valid SFPolygon will be initialized with a copy of p.
func NewSFPolygonXY ¶
NewSFPolygonXY constructs and returns a new SFPolygon object based on the given external and (optionally) internal shapes.
func NewSFPolygonXYZ ¶
NewSFPolygonXY constructs and returns a new SFPolygon object based on the given external and (optionally) internal shapes.
func NullSFPolygon ¶
func NullSFPolygon() SFPolygon
NullSFPolygon constructs and returns a new null SFPolygon object.
func (SFPolygon) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if p is null.
func (SFPolygon) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if p is null or if the contained SFPolygon is a zero value.
func (SFPolygon) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will return the GeoJSON encoded representation of p, or "null" if p is null.
func (SFPolygon) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode p into its interface{} representation for use in a map[string]interface{} by passing it through JSON.Unmarshal if valid, or the 'null' keyword otherwise.
func (*SFPolygon) Null ¶
func (p *SFPolygon) Null()
Null will set p to null; p.Valid will be false, and p.Polygon will contain no meaningful value.
func (*SFPolygon) Scan ¶
Scan implements the database/sql Scanner interface. It expects to receive a valid WKB encoded []byte describing a Polygon, or NULL as a nil from an SQL database. A zero-length or nil []byte will be considered NULL, and p will be nulled. Otherwise, the value will be passed to types.SFPolygon to be scanned and parsed as a WKB Polygon.
func (*SFPolygon) Set ¶
Set copies the given types.SFPolygon value into p. If the given value is nil, p will be nulled.
func (*SFPolygon) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It expects to receive a valid GeoJSON Geometry of the type Polygon, and will assign the value of that data to p. If the incoming JSON is the 'null' keyword, p will have no valid value.
func (SFPolygon) Value ¶
Value implements the database/sql/driver Valuer interface. It will return the value of p as a driver.Value. If p is null, nil will be returned.
func (SFPolygon) ValueOrZero ¶
ValueOrZero will return the value of p if it is valid, or a newly constructed zero-value types.SFPolygon otherwise.
type String ¶
type String struct {
sql.NullString
}
String is a wrapper around the database/sql NullString type that implements all of the pyrrho/encoding/types interfaces detailed in the package comments that sql.NullString doesn't implement out of the box.
If the String is valid and contains the empty string, it will be considered non-nil, and of zero value.
func NewString ¶
NewString constructs and returns a new, valid String initialized with the value of the given s.
func (String) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if s is null.
func (String) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if s is null or if its value is the empty string.
func (String) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will return the value of s if valid, otherwise 'null'.
func (String) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode s into an interface{} representation for use in a map[string]interface{} if valid, or return nil otherwise.
func (*String) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It will decode a given []byte into s, so long as the provided []byte is a valid JSON string or a null.
An empty string will result in a valid-but-empty String. The keyword 'null' will result in a null String. The string '"null"' is considered to be a string -- not a keyword -- and will result in a valid String.
If the decode fails, the value of s will be unchanged.
func (String) ValueOrZero ¶
ValueOrZero returns the value of s if it is valid; otherwise it returns the zero value for a string ("").
type Time ¶
Time is a nullable wrapper around the time.Time type implementing all of the pyrrho/encoding/types interfaces detailed in the package comments.
If the Time is valid and contains the zero time instant, it will be considered non-null, and of zero value.
func NewTime ¶
NewTime constructs and returns a new, valid Time initialized with the value of the given t.
func NewTimeStr ¶
NewTimeStr parses a given string, s, as an ISO 8601 and returns
func (Time) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if t is null.
func (Time) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if t is null or if its value is the zero time instant.
func (Time) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will encode t into its JSON RFC 3339 string representation if valid, or 'null' otherwise.
func (Time) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode t into an interface{} representation for use in a map[Time]interface{} if valid, or return nil otherwise.
func (*Time) Scan ¶
Scan implements the database/sql Scanner interface. It will receive a value from an SQL database and assign it to t, so long as the provided data is of type nil or time.Time. All other types will result in an error.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It will decode a given []byte into t so long as the provided []byte is a valid JSON representation of an ISO 8601 string. Empty strings and the 'null' keyword will both decode into a null NullTime.
If the decode fails, the value of t will be unchanged.
func (Time) Value ¶
Value implements the database/sql/driver Valuer interface. As time.Time and nil are both valid types to be stored in a driver.Value, it will return this NullTime's value if valid, or nil otherwise.
func (Time) ValueOrZero ¶
ValueOrZero returns the value of t if it is valid; otherwise it returns the zero value for a time.Time.
type Uint8 ¶
Uint8 is a nullable wrapper around the uint8 type that implementing all of the pyrrho/encoding/types interfaces detailed in the package comments.
If the Uint8 is valid and contains 0, it will be considered non-nil, and of zero value.
func NewUint8 ¶
NewUint8 constructs and returns a new, valid Uint8 initialized with the value of the given i.
func (Uint8) IsNil ¶
IsNil implements the pyrrho/encoding IsNiler interface. It will return true if i is null.
func (Uint8) IsZero ¶
IsZero implements the pyrrho/encoding IsZeroer interface. It will return true if i is null or if its value is 0.
func (Uint8) MarshalJSON ¶
MarshalJSON implements the encoding/json Marshaler interface. It will encode i into its JSON representation if valid, or 'null' otherwise.
func (Uint8) MarshalMapValue ¶
MarshalMapValue implements the pyrrho/encoding/maps Marshaler interface. It will encode i into its interface{} representation for use in a map[string]interface{} if valid, or return nil otherwise.
func (*Uint8) Scan ¶
Scan implements the database/sql Scanner interface. It will receive a value from an SQL database and assign it to i, so long as the provided data is of type nil, uint8, string, or another integer or float type that doesn't overflow uint8. All other types will result in an error.
func (*Uint8) UnmarshalJSON ¶
UnmarshalJSON implements the encoding/json Unmarshaler interface. It will decode a given []byte into i, so long as the provided []byte is a valid JSON representation of an int. The 'null' keyword will decode into a null Uint8.
If the decode fails, the value of i will be unchanged.
func (Uint8) Value ¶
Value implements the database/sql/driver Valuer interface. Nil is a valid type to be stored in a driver.Value, but uint8 isn't, so if this Uint8 is valid it will cast its uint8 to an int64.
func (Uint8) ValueOrZero ¶
ValueOrZero returns the value of i if it is valid; otherwise it returns the zero value for a uint8 (0).