Documentation ¶
Overview ¶
Package null provides nullable types (based on database/sql) that can be parsed to and from JSON.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
Bool is a nullable boolean type based on sql.NullBool, that supports parsing to/from JSON.
func NewBool ¶
NewBool returns a new nullable Bool object. This is equivalent to `null.Bool{sql.NullBool{Bool: b, Valid: valid}}`.
func (Bool) MarshalJSON ¶
MarshalJSON implements the encoding json interface.
func (*Bool) SetValid ¶
SetValid sets the value and valid to true.
type Float64 ¶
type Float64 struct {
sql.NullFloat64
}
Float64 is a nullable float64 type based on sql.NullFloat64, that supports parsing to/from JSON.
func NewFloat64 ¶
NewFloat64 returns a new nullable Float64 object. This is equivalent to `null.Float64{sql.NullFloat64{Float64: f, Valid: valid}}`.
func (Float64) MarshalJSON ¶
MarshalJSON implements the encoding json interface.
func (*Float64) SetNil ¶
func (f *Float64) SetNil()
SetNil sets the value to default and valid to false.
func (*Float64) SetValid ¶
SetValid sets the value and valid to true.
type Int32 ¶
Int32 is a nullable int32 type based on sql.NullInt32, that supports parsing to/from JSON.
func NewInt32 ¶
NewInt32 returns a new nullable Int32 object. This is equivalent to `null.Int32{sql.NullInt32{Int32: i, Valid: valid}}`.
func (Int32) MarshalJSON ¶
MarshalJSON implements the encoding json interface.
func (*Int32) SetNil ¶
func (i *Int32) SetNil()
SetNil sets the value to default and valid to false.
func (*Int32) SetValid ¶
SetValid sets the value and valid to true.
type Int64 ¶
Int64 is a nullable int64 type based on sql.NullInt64, that supports parsing to/from JSON.
func NewInt64 ¶
NewInt64 returns a new nullable Int64 object. This is equivalent to `null.Int64{sql.NullInt64{Int64: i, Valid: valid}}`.
func (Int64) MarshalJSON ¶
MarshalJSON implements the encoding json interface.
func (*Int64) SetNil ¶
func (i *Int64) SetNil()
SetNil sets the value to default and valid to false.
func (*Int64) SetValid ¶
SetValid sets the value and valid to true.
type String ¶
type String struct {
sql.NullString
}
String is a nullable string type based on sql.NullString, that supports parsing to/from JSON.
func NewString ¶
NewString returns a new nullable String object. This is equivalent to `null.String{sql.NullString{String: s, Valid: valid}}`.
func (String) MarshalJSON ¶
MarshalJSON implements the encoding json interface.
func (*String) SetNil ¶
func (s *String) SetNil()
SetNil sets the value to default and valid to false.
func (*String) SetValid ¶
SetValid sets the value and valid to true.
type Time ¶
Time is a nullable time.Time, that supports parsing to/from JSON.
func NewTime ¶
NewTime returns a new nullable time.Time object. This is equivalent to `null.Time{Time: t, Valid: valid}`.
func (Time) MarshalJSON ¶
MarshalJSON implements the encoding json interface.
func (*Time) Scan ¶
Scan implements the Scanner interface.
func (*Time) SetValid ¶
SetValid sets the value and valid to true.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements the encoding json interface.