zero

package
v5.0.0-...-cdb95c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2016 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package zero contains SQL types that consider zero input and null input to be equivalent with convenient support for JSON and text marshaling. Types in this package will JSON marshal to their zero value, even if null. Use the null parent package if you don't want this.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	sql.NullBool
}

Bool is a nullable bool. False input is considered null. JSON marshals to false if null. Considered null to SQL unmarshaled from a false value.

func BoolFrom

func BoolFrom(b bool) Bool

BoolFrom creates a new Bool that will be null if false.

func BoolFromPtr

func BoolFromPtr(b *bool) Bool

BoolFromPtr creates a new Bool that be null if b is nil.

func NewBool

func NewBool(b bool, valid bool) Bool

NewBool creates a new Bool

func (Bool) IsZero

func (b Bool) IsZero() bool

IsZero returns true for null or zero Bools, for future omitempty support (Go 1.4?)

func (Bool) MarshalJSON

func (b Bool) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode null if this Bool is null.

func (Bool) MarshalText

func (b Bool) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Bool is null.

func (Bool) Ptr

func (b Bool) Ptr() *bool

Ptr returns a poBooler to this Bool's value, or a nil poBooler if this Bool is null.

func (*Bool) SetValid

func (b *Bool) SetValid(v bool)

SetValid changes this Bool's value and also sets it to be non-null.

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. "false" will be considered a null Bool. It also supports unmarshalling a sql.NullBool.

func (*Bool) UnmarshalText

func (b *Bool) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Bool if the input is a false or not a bool. It will return an error if the input is not a float, blank, or "null".

type Bytes

type Bytes struct {
	NullBytes
}

Bytes is a nullable []byte. JSON marshals to zero if null. Considered null to SQL if zero.

func BytesFrom

func BytesFrom(b []byte) Bytes

BytesFrom creates a new Bytes that will be null if len zero.

func BytesFromPtr

func BytesFromPtr(b *[]byte) Bytes

BytesFromPtr creates a new Bytes that be null if len zero.

func NewBytes

func NewBytes(b []byte, valid bool) Bytes

NewBytes creates a new Bytes

func (Bytes) IsZero

func (b Bytes) IsZero() bool

IsZero returns true for null or zero Bytes's, for future omitempty support (Go 1.4?)

func (Bytes) MarshalJSON

func (b Bytes) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode null if the Bytes is nil.

func (Bytes) MarshalText

func (b Bytes) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode nil if the Bytes is invalid.

func (Bytes) Ptr

func (b Bytes) Ptr() *[]byte

Ptr returns a pointer to this Bytes's value, or a nil pointer if this Bytes is null.

func (*Bytes) SetValid

func (b *Bytes) SetValid(n []byte)

SetValid changes this Bytes's value and also sets it to be non-null.

func (*Bytes) UnmarshalJSON

func (b *Bytes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. If data is len 0 or nil, it will unmarshal to JSON null. If not, it will copy your data slice into Bytes.

func (*Bytes) UnmarshalText

func (b *Bytes) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to nil if the text is nil or len 0.

type Float32

type Float32 struct {
	NullFloat32
}

Float32 is a nullable float32. Zero input will be considered null. JSON marshals to zero if null. Considered null to SQL if zero.

func Float32From

func Float32From(f float32) Float32

Float32From creates a new Float32 that will be null if zero.

func Float32FromPtr

func Float32FromPtr(f *float32) Float32

Float32FromPtr creates a new Float32 that be null if f is nil.

func NewFloat32

func NewFloat32(f float32, valid bool) Float32

NewFloat32 creates a new Float32

func (Float32) IsZero

func (f Float32) IsZero() bool

IsZero returns true for null or zero Float32's, for future omitempty support (Go 1.4?)

func (Float32) MarshalJSON

func (f Float32) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode null if this Float32 is null.

func (Float32) MarshalText

func (f Float32) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Float32 is null.

func (Float32) Ptr

func (f Float32) Ptr() *float32

Ptr returns a poFloater to this Float32's value, or a nil poFloater if this Float32 is null.

func (*Float32) SetValid

func (f *Float32) SetValid(v float32)

SetValid changes this Float32's value and also sets it to be non-null.

func (*Float32) UnmarshalJSON

func (f *Float32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Float32. It also supports unmarshalling a sql.NullFloat32.

func (*Float32) UnmarshalText

func (f *Float32) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Float32 if the input is a blank, zero, or not a float. It will return an error if the input is not a float, blank, or "null".

type Float64

type Float64 struct {
	sql.NullFloat64
}

Float64 is a nullable float64. Zero input will be considered null. JSON marshals to zero if null. Considered null to SQL if zero.

func Float64From

func Float64From(f float64) Float64

Float64From creates a new Float64 that will be null if zero.

func Float64FromPtr

func Float64FromPtr(f *float64) Float64

Float64FromPtr creates a new Float64 that be null if f is nil.

func NewFloat64

func NewFloat64(f float64, valid bool) Float64

NewFloat64 creates a new Float64

func (Float64) IsZero

func (f Float64) IsZero() bool

IsZero returns true for null or zero Float64's, for future omitempty support (Go 1.4?)

func (Float64) MarshalJSON

func (f Float64) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode null if this Float64 is null.

func (Float64) MarshalText

func (f Float64) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Float64 is null.

func (Float64) Ptr

func (f Float64) Ptr() *float64

Ptr returns a poFloater to this Float64's value, or a nil poFloater if this Float64 is null.

func (*Float64) SetValid

func (f *Float64) SetValid(v float64)

SetValid changes this Float64's value and also sets it to be non-null.

func (*Float64) UnmarshalJSON

func (f *Float64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Float64. It also supports unmarshalling a sql.NullFloat64.

func (*Float64) UnmarshalText

func (f *Float64) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Float64 if the input is a blank, zero, or not a float. It will return an error if the input is not a float, blank, or "null".

type Int

type Int struct {
	NullInt
}

Int is a nullable int. JSON marshals to zero if null. Considered null to SQL if zero.

func IntFrom

func IntFrom(i int) Int

IntFrom creates a new Int that will be null if zero.

func IntFromPtr

func IntFromPtr(i *int) Int

IntFromPtr creates a new Int that be null if i is nil.

func NewInt

func NewInt(i int, valid bool) Int

NewInt creates a new Int

func (Int) IsZero

func (i Int) IsZero() bool

IsZero returns true for null or zero Ints, for future omitempty support (Go 1.4?)

func (Int) MarshalJSON

func (i Int) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Int is null.

func (Int) MarshalText

func (i Int) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Int is null.

func (Int) Ptr

func (i Int) Ptr() *int

Ptr returns a pointer to this Int's value, or a nil pointer if this Int is null.

func (*Int) SetValid

func (i *Int) SetValid(n int)

SetValid changes this Int's value and also sets it to be non-null.

func (*Int) UnmarshalJSON

func (i *Int) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Int. It also supports unmarshalling a sql.NullInt.

func (*Int) UnmarshalText

func (i *Int) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

type Int16

type Int16 struct {
	NullInt16
}

Int16 is a nullable int16. JSON marshals to zero if null. Considered null to SQL if zero.

func Int16From

func Int16From(i int16) Int16

Int16From creates a new Int16 that will be null if zero.

func Int16FromPtr

func Int16FromPtr(i *int16) Int16

Int16FromPtr creates a new Int16 that be null if i is nil.

func NewInt16

func NewInt16(i int16, valid bool) Int16

NewInt16 creates a new Int16

func (Int16) IsZero

func (i Int16) IsZero() bool

IsZero returns true for null or zero Int16s, for future omitempty support (Go 1.4?)

func (Int16) MarshalJSON

func (i Int16) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Int16 is null.

func (Int16) MarshalText

func (i Int16) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Int16 is null.

func (Int16) Ptr

func (i Int16) Ptr() *int16

Ptr returns a pointer to this Int16's value, or a nil pointer if this Int16 is null.

func (*Int16) SetValid

func (i *Int16) SetValid(n int16)

SetValid changes this Int16's value and also sets it to be non-null.

func (*Int16) UnmarshalJSON

func (i *Int16) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Int16. It also supports unmarshalling a sql.NullInt16.

func (*Int16) UnmarshalText

func (i *Int16) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int16 if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

type Int32

type Int32 struct {
	NullInt32
}

Int32 is a nullable int32. JSON marshals to zero if null. Considered null to SQL if zero.

func Int32From

func Int32From(i int32) Int32

Int32From creates a new Int32 that will be null if zero.

func Int32FromPtr

func Int32FromPtr(i *int32) Int32

Int32FromPtr creates a new Int32 that be null if i is nil.

func NewInt32

func NewInt32(i int32, valid bool) Int32

NewInt32 creates a new Int32

func (Int32) IsZero

func (i Int32) IsZero() bool

IsZero returns true for null or zero Int32s, for future omitempty support (Go 1.4?)

func (Int32) MarshalJSON

func (i Int32) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Int32 is null.

func (Int32) MarshalText

func (i Int32) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Int32 is null.

func (Int32) Ptr

func (i Int32) Ptr() *int32

Ptr returns a pointer to this Int32's value, or a nil pointer if this Int32 is null.

func (*Int32) SetValid

func (i *Int32) SetValid(n int32)

SetValid changes this Int32's value and also sets it to be non-null.

func (*Int32) UnmarshalJSON

func (i *Int32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Int32. It also supports unmarshalling a sql.NullInt32.

func (*Int32) UnmarshalText

func (i *Int32) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int32 if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

type Int64

type Int64 struct {
	sql.NullInt64
}

Int64 is a nullable int64. JSON marshals to zero if null. Considered null to SQL if zero.

func Int64From

func Int64From(i int64) Int64

Int64From creates a new Int64 that will be null if zero.

func Int64FromPtr

func Int64FromPtr(i *int64) Int64

Int64FromPtr creates a new Int64 that be null if i is nil.

func NewInt64

func NewInt64(i int64, valid bool) Int64

NewInt64 creates a new Int64

func (Int64) IsZero

func (i Int64) IsZero() bool

IsZero returns true for null or zero Int64s, for future omitempty support (Go 1.4?)

func (Int64) MarshalJSON

func (i Int64) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Int64 is null.

func (Int64) MarshalText

func (i Int64) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Int64 is null.

func (Int64) Ptr

func (i Int64) Ptr() *int64

Ptr returns a pointer to this Int64's value, or a nil pointer if this Int64 is null.

func (*Int64) SetValid

func (i *Int64) SetValid(n int64)

SetValid changes this Int64's value and also sets it to be non-null.

func (*Int64) UnmarshalJSON

func (i *Int64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Int64. It also supports unmarshalling a sql.NullInt64.

func (*Int64) UnmarshalText

func (i *Int64) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int64 if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

type Int8

type Int8 struct {
	NullInt8
}

Int8 is a nullable int8. JSON marshals to zero if null. Considered null to SQL if zero.

func Int8From

func Int8From(i int8) Int8

Int8From creates a new Int8 that will be null if zero.

func Int8FromPtr

func Int8FromPtr(i *int8) Int8

Int8FromPtr creates a new Int8 that be null if i is nil.

func NewInt8

func NewInt8(i int8, valid bool) Int8

NewInt8 creates a new Int8

func (Int8) IsZero

func (i Int8) IsZero() bool

IsZero returns true for null or zero Int8s, for future omitempty support (Go 1.4?)

func (Int8) MarshalJSON

func (i Int8) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Int8 is null.

func (Int8) MarshalText

func (i Int8) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Int8 is null.

func (Int8) Ptr

func (i Int8) Ptr() *int8

Ptr returns a pointer to this Int8's value, or a nil pointer if this Int8 is null.

func (*Int8) SetValid

func (i *Int8) SetValid(n int8)

SetValid changes this Int8's value and also sets it to be non-null.

func (*Int8) UnmarshalJSON

func (i *Int8) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Int8. It also supports unmarshalling a sql.NullInt8.

func (*Int8) UnmarshalText

func (i *Int8) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int8 if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

type JSON

type JSON struct {
	NullJSON
}

JSON is a nullable []byte. JSON marshals to zero if null. Considered null to SQL if zero.

func JSONFrom

func JSONFrom(b []byte) JSON

JSONFrom creates a new JSON that will be null if len zero.

func JSONFromPtr

func JSONFromPtr(b *[]byte) JSON

JSONFromPtr creates a new JSON that be null if len zero.

func NewJSON

func NewJSON(b []byte, valid bool) JSON

NewJSON creates a new JSON

func (JSON) IsZero

func (j JSON) IsZero() bool

IsZero returns true for null or zero JSON's, for future omitempty support (Go 1.4?)

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode null if the JSON is nil.

func (JSON) MarshalText

func (j JSON) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode nil if the JSON is invalid.

func (JSON) Ptr

func (j JSON) Ptr() *[]byte

Ptr returns a pointer to this JSON's value, or a nil pointer if this JSON is null.

func (*JSON) SetValid

func (j *JSON) SetValid(n []byte)

SetValid changes this JSON's value and also sets it to be non-null.

func (*JSON) UnmarshalJSON

func (j *JSON) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. If data is len 0 or nil, it will unmarshal to JSON null. If not, it will copy your data slice into JSON.

func (*JSON) UnmarshalText

func (j *JSON) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to nil if the text is nil or len 0.

type NullBytes

type NullBytes struct {
	Bytes []byte
	Valid bool
}

NullBytes is a nullable byte slice.

func (*NullBytes) Scan

func (n *NullBytes) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullBytes) Value

func (n NullBytes) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullFloat32

type NullFloat32 struct {
	Float32 float32
	Valid   bool
}

func (*NullFloat32) Scan

func (n *NullFloat32) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullFloat32) Value

func (n NullFloat32) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullInt

type NullInt struct {
	Int   int
	Valid bool
}

func (*NullInt) Scan

func (n *NullInt) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullInt) Value

func (n NullInt) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullInt16

type NullInt16 struct {
	Int16 int16
	Valid bool
}

func (*NullInt16) Scan

func (n *NullInt16) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullInt16) Value

func (n NullInt16) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullInt32

type NullInt32 struct {
	Int32 int32
	Valid bool
}

func (*NullInt32) Scan

func (n *NullInt32) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullInt32) Value

func (n NullInt32) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullInt8

type NullInt8 struct {
	Int8  int8
	Valid bool
}

func (*NullInt8) Scan

func (n *NullInt8) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullInt8) Value

func (n NullInt8) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullJSON

type NullJSON struct {
	JSON  []byte
	Valid bool
}

NullJSON is a nullable byte slice.

func (*NullJSON) Scan

func (n *NullJSON) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullJSON) Value

func (n NullJSON) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullUint

type NullUint struct {
	Uint  uint
	Valid bool
}

func (*NullUint) Scan

func (n *NullUint) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullUint) Value

func (n NullUint) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullUint16

type NullUint16 struct {
	Uint16 uint16
	Valid  bool
}

func (*NullUint16) Scan

func (n *NullUint16) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullUint16) Value

func (n NullUint16) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullUint32

type NullUint32 struct {
	Uint32 uint32
	Valid  bool
}

func (*NullUint32) Scan

func (n *NullUint32) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullUint32) Value

func (n NullUint32) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullUint64

type NullUint64 struct {
	Uint64 uint64
	Valid  bool
}

NullUint64 is a replica of sql.NullInt64 for uint64 types.

func (*NullUint64) Scan

func (n *NullUint64) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullUint64) Value

func (n NullUint64) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullUint8

type NullUint8 struct {
	Uint8 uint8
	Valid bool
}

func (*NullUint8) Scan

func (n *NullUint8) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullUint8) Value

func (n NullUint8) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type String

type String struct {
	sql.NullString
}

String is a nullable string. JSON marshals to a blank string if null. Considered null to SQL if zero.

func NewString

func NewString(s string, valid bool) String

NewString creates a new String

func StringFrom

func StringFrom(s string) String

StringFrom creates a new String that will be null if s is blank.

func StringFromPtr

func StringFromPtr(s *string) String

StringFromPtr creates a new String that be null if s is nil or blank. It will make s point to the String's value.

func (String) IsZero

func (s String) IsZero() bool

IsZero returns true for null or empty strings, for potential future omitempty support.

func (String) MarshalText

func (s String) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a blank string when this String is null.

func (String) Ptr

func (s String) Ptr() *string

Ptr returns a pointer to this String's value, or a nil pointer if this String is null.

func (*String) SetValid

func (s *String) SetValid(v string)

SetValid changes this String's value and also sets it to be non-null.

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(data []byte) error

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

func (s *String) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null String if the input is a blank string.

type Time

type Time struct {
	Time  time.Time
	Valid bool
}

Time is a nullable time.Time. JSON marshals to the zero value for time.Time if null. Considered to be null to SQL if zero.

func NewTime

func NewTime(t time.Time, valid bool) Time

NewTime creates a new Time.

func TimeFrom

func TimeFrom(t time.Time) Time

TimeFrom creates a new Time that will be null if t is the zero value.

func TimeFromPtr

func TimeFromPtr(t *time.Time) Time

TimeFromPtr creates a new Time that will be null if t is nil or *t is the zero value.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode the zero value of time.Time if this time is invalid.

func (Time) MarshalText

func (t Time) MarshalText() ([]byte, error)

func (Time) Ptr

func (t Time) Ptr() *time.Time

Ptr returns a pointer to this Time's value, or a nil pointer if this Time is zero.

func (*Time) Scan

func (t *Time) Scan(value interface{}) error

Scan implements Scanner interface.

func (*Time) SetValid

func (t *Time) SetValid(v time.Time)

SetValid changes this Time's value and sets it to be non-null.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports string, object (e.g. pq.NullTime and friends) and null input.

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(text []byte) error

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Uint

type Uint struct {
	NullUint
}

Uint is a nullable uint. JSON marshals to zero if null. Considered null to SQL if zero.

func NewUint

func NewUint(i uint, valid bool) Uint

NewUint creates a new Uint

func UintFrom

func UintFrom(i uint) Uint

UintFrom creates a new Uint that will be null if zero.

func UintFromPtr

func UintFromPtr(i *uint) Uint

UintFromPtr creates a new Uint that be null if i is nil.

func (Uint) IsZero

func (i Uint) IsZero() bool

IsZero returns true for null or zero Uints, for future omitempty support (Go 1.4?)

func (Uint) MarshalJSON

func (i Uint) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Uint is null.

func (Uint) MarshalText

func (i Uint) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Uint is null.

func (Uint) Ptr

func (i Uint) Ptr() *uint

Ptr returns a pointer to this Uint's value, or a nil pointer if this Uint is null.

func (*Uint) SetValid

func (i *Uint) SetValid(n uint)

SetValid changes this Uint's value and also sets it to be non-null.

func (*Uint) UnmarshalJSON

func (i *Uint) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Uint. It also supports unmarshalling a sql.NullUint.

func (*Uint) UnmarshalText

func (i *Uint) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Uint if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

type Uint16

type Uint16 struct {
	NullUint16
}

Uint16 is a nullable uint16. JSON marshals to zero if null. Considered null to SQL if zero.

func NewUint16

func NewUint16(i uint16, valid bool) Uint16

NewUint16 creates a new Uint16

func Uint16From

func Uint16From(i uint16) Uint16

Uint16From creates a new Uint16 that will be null if zero.

func Uint16FromPtr

func Uint16FromPtr(i *uint16) Uint16

Uint16FromPtr creates a new Uint16 that be null if i is nil.

func (Uint16) IsZero

func (i Uint16) IsZero() bool

IsZero returns true for null or zero Uint16s, for future omitempty support (Go 1.4?)

func (Uint16) MarshalJSON

func (i Uint16) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Uint16 is null.

func (Uint16) MarshalText

func (i Uint16) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Uint16 is null.

func (Uint16) Ptr

func (i Uint16) Ptr() *uint16

Ptr returns a pointer to this Uint16's value, or a nil pointer if this Uint16 is null.

func (*Uint16) SetValid

func (i *Uint16) SetValid(n uint16)

SetValid changes this Uint16's value and also sets it to be non-null.

func (*Uint16) UnmarshalJSON

func (i *Uint16) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Uint16. It also supports unmarshalling a sql.NullUint16.

func (*Uint16) UnmarshalText

func (i *Uint16) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Uint16 if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

type Uint32

type Uint32 struct {
	NullUint32
}

Uint32 is a nullable uint32. JSON marshals to zero if null. Considered null to SQL if zero.

func NewUint32

func NewUint32(i uint32, valid bool) Uint32

NewUint32 creates a new Uint32

func Uint32From

func Uint32From(i uint32) Uint32

Uint32From creates a new Uint32 that will be null if zero.

func Uint32FromPtr

func Uint32FromPtr(i *uint32) Uint32

Uint32FromPtr creates a new Uint32 that be null if i is nil.

func (Uint32) IsZero

func (i Uint32) IsZero() bool

IsZero returns true for null or zero Uint32s, for future omitempty support (Go 1.4?)

func (Uint32) MarshalJSON

func (i Uint32) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Uint32 is null.

func (Uint32) MarshalText

func (i Uint32) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Uint32 is null.

func (Uint32) Ptr

func (i Uint32) Ptr() *uint32

Ptr returns a pointer to this Uint32's value, or a nil pointer if this Uint32 is null.

func (*Uint32) SetValid

func (i *Uint32) SetValid(n uint32)

SetValid changes this Uint32's value and also sets it to be non-null.

func (*Uint32) UnmarshalJSON

func (i *Uint32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Uint32. It also supports unmarshalling a sql.NullUint32.

func (*Uint32) UnmarshalText

func (i *Uint32) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Uint32 if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

type Uint64

type Uint64 struct {
	NullUint64
}

Uint64 is an nullable uint64. It does not consider zero values to be null. It will decode to null, not zero, if null.

func NewUint64

func NewUint64(i uint64, valid bool) Uint64

NewUint64 creates a new Uint64

func Uint64From

func Uint64From(i uint64) Uint64

Uint64From creates a new Uint64 that will be null if zero.

func Uint64FromPtr

func Uint64FromPtr(i *uint64) Uint64

Uint64FromPtr creates a new Uint64 that be null if i is nil.

func (Uint64) IsZero

func (i Uint64) IsZero() bool

IsZero returns true for null or zero Uint64s, for future omitempty support (Go 1.4?)

func (Uint64) MarshalJSON

func (i Uint64) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Uint64 is null.

func (Uint64) MarshalText

func (i Uint64) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Uint64 is null.

func (Uint64) Ptr

func (i Uint64) Ptr() *uint64

Ptr returns a pointer to this Uint64's value, or a nil pointer if this Uint64 is null.

func (*Uint64) SetValid

func (i *Uint64) SetValid(n uint64)

SetValid changes this Uint64's value and also sets it to be non-null.

func (*Uint64) UnmarshalJSON

func (i *Uint64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Uint64. It also supports unmarshalling a sql.NullUint64.

func (*Uint64) UnmarshalText

func (i *Uint64) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Uint64 if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

type Uint8

type Uint8 struct {
	NullUint8
}

Uint8 is a nullable uint8. JSON marshals to zero if null. Considered null to SQL if zero.

func NewUint8

func NewUint8(i uint8, valid bool) Uint8

NewUint8 creates a new Uint8

func Uint8From

func Uint8From(i uint8) Uint8

Uint8From creates a new Uint8 that will be null if zero.

func Uint8FromPtr

func Uint8FromPtr(i *uint8) Uint8

Uint8FromPtr creates a new Uint8 that be null if i is nil.

func (Uint8) IsZero

func (i Uint8) IsZero() bool

IsZero returns true for null or zero Uint8s, for future omitempty support (Go 1.4?)

func (Uint8) MarshalJSON

func (i Uint8) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode 0 if this Uint8 is null.

func (Uint8) MarshalText

func (i Uint8) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a zero if this Uint8 is null.

func (Uint8) Ptr

func (i Uint8) Ptr() *uint8

Ptr returns a pointer to this Uint8's value, or a nil pointer if this Uint8 is null.

func (*Uint8) SetValid

func (i *Uint8) SetValid(n uint8)

SetValid changes this Uint8's value and also sets it to be non-null.

func (*Uint8) UnmarshalJSON

func (i *Uint8) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Uint8. It also supports unmarshalling a sql.NullUint8.

func (*Uint8) UnmarshalText

func (i *Uint8) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Uint8 if the input is a blank, zero, or not an integer. It will return an error if the input is not an integer, blank, or "null".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL