Documentation ¶
Overview ¶
Package null contains types which can be NULL in some storage engines.
The aim is to import database/sql to avoid the dependency on SQL. Null values can occur everywhere hence we want to keep the deps minimal.
Index ¶
- Variables
- type Bool
- func (a Bool) Append(args []interface{}) []interface{}
- func (a Bool) GoString() string
- func (a Bool) IsZero() bool
- func (m *Bool) Marshal() (dAtA []byte, err error)
- func (a Bool) MarshalBinary() (data []byte, err error)
- func (a Bool) MarshalJSON() ([]byte, error)
- func (a Bool) MarshalText() ([]byte, error)
- func (m *Bool) MarshalTo(dAtA []byte) (int, error)
- func (m *Bool) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Bool) Ptr() *bool
- func (a *Bool) Reset()
- func (a *Bool) Scan(value interface{}) (err error)
- func (a *Bool) SetPtr(v *bool)
- func (a *Bool) SetValid(v bool)
- func (m Bool) Size() (n int)
- func (a Bool) String() string
- func (m *Bool) Unmarshal(dAtA []byte) error
- func (a *Bool) UnmarshalBinary(data []byte) error
- func (a *Bool) UnmarshalJSON(data []byte) error
- func (a *Bool) UnmarshalText(text []byte) (err error)
- func (a Bool) Value() (driver.Value, error)
- func (a Bool) WriteTo(d Dialecter, w *bytes.Buffer) (err error)
- type Decimal
- func (d Decimal) Equal(d2 Decimal) bool
- func (d *Decimal) Fake(fieldName string) (hasFakeDataApplied bool, err error)
- func (d Decimal) Float64() (value float64)
- func (d Decimal) GoString() string
- func (d Decimal) Int64() (value int64, scale int32)
- func (d *Decimal) Marshal() (dAtA []byte, err error)
- func (d Decimal) MarshalBinary() (data []byte, err error)
- func (d Decimal) MarshalJSON() ([]byte, error)
- func (d Decimal) MarshalText() (text []byte, err error)
- func (d *Decimal) MarshalTo(dAtA []byte) (int, error)
- func (d *Decimal) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (d Decimal) Ptr() *Decimal
- func (d *Decimal) Reset()
- func (d *Decimal) Scan(value interface{}) (err error)
- func (d *Decimal) SetPtr(v *Decimal)
- func (d Decimal) Size() (n int)
- func (d Decimal) SizeVT() (n int)
- func (d Decimal) String() string
- func (d *Decimal) Unmarshal(dAtA []byte) error
- func (d *Decimal) UnmarshalBinary(data []byte) error
- func (d *Decimal) UnmarshalJSON(b []byte) (err error)
- func (d *Decimal) UnmarshalText(text []byte) (err error)
- func (d Decimal) Value() (driver.Value, error)
- type Dialecter
- type Float64
- func (a Float64) Append(args []interface{}) []interface{}
- func (a Float64) GoString() string
- func (a Float64) IsZero() bool
- func (m *Float64) Marshal() (dAtA []byte, err error)
- func (a Float64) MarshalBinary() (data []byte, err error)
- func (a Float64) MarshalJSON() ([]byte, error)
- func (a Float64) MarshalText() ([]byte, error)
- func (m *Float64) MarshalTo(dAtA []byte) (int, error)
- func (m *Float64) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Float64) Ptr() *float64
- func (a *Float64) Reset()
- func (a *Float64) Scan(value interface{}) (err error)
- func (a *Float64) SetPtr(v *float64)
- func (a *Float64) SetValid(n float64)
- func (m Float64) Size() (n int)
- func (a Float64) String() string
- func (m *Float64) Unmarshal(dAtA []byte) error
- func (a *Float64) UnmarshalBinary(data []byte) error
- func (a *Float64) UnmarshalJSON(data []byte) error
- func (a *Float64) UnmarshalText(text []byte) (err error)
- func (a Float64) Value() (driver.Value, error)
- func (a Float64) WriteTo(_ Dialecter, w *bytes.Buffer) (err error)
- type Int16
- func (a Int16) Append(args []interface{}) []interface{}
- func (a Int16) GoString() string
- func (a Int16) IsZero() bool
- func (m *Int16) Marshal() (dAtA []byte, err error)
- func (a Int16) MarshalBinary() (data []byte, err error)
- func (a Int16) MarshalJSON() ([]byte, error)
- func (a Int16) MarshalText() ([]byte, error)
- func (m *Int16) MarshalTo(dAtA []byte) (int, error)
- func (m *Int16) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Int16) Ptr() *int16
- func (a *Int16) Reset()
- func (a *Int16) Scan(value interface{}) (err error)
- func (a *Int16) SetPtr(v *int16)
- func (a *Int16) SetValid(n int16)
- func (m Int16) Size() (n int)
- func (a Int16) String() string
- func (m *Int16) Unmarshal(dAtA []byte) error
- func (a *Int16) UnmarshalBinary(data []byte) error
- func (a *Int16) UnmarshalJSON(data []byte) error
- func (a *Int16) UnmarshalText(text []byte) error
- func (a Int16) Value() (driver.Value, error)
- func (a Int16) WriteTo(_ Dialecter, w *bytes.Buffer) (err error)
- type Int32
- func (a Int32) Append(args []interface{}) []interface{}
- func (a Int32) GoString() string
- func (a Int32) IsZero() bool
- func (m *Int32) Marshal() (dAtA []byte, err error)
- func (a Int32) MarshalBinary() (data []byte, err error)
- func (a Int32) MarshalJSON() ([]byte, error)
- func (a Int32) MarshalText() ([]byte, error)
- func (m *Int32) MarshalTo(dAtA []byte) (int, error)
- func (m *Int32) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Int32) Ptr() *int32
- func (a *Int32) Reset()
- func (a *Int32) Scan(value interface{}) (err error)
- func (a *Int32) SetPtr(v *int32)
- func (a *Int32) SetValid(n int32)
- func (m Int32) Size() (n int)
- func (a Int32) String() string
- func (m *Int32) Unmarshal(dAtA []byte) error
- func (a *Int32) UnmarshalBinary(data []byte) error
- func (a *Int32) UnmarshalJSON(data []byte) error
- func (a *Int32) UnmarshalText(text []byte) error
- func (a Int32) WriteTo(_ Dialecter, w *bytes.Buffer) (err error)
- type Int64
- func (a Int64) Append(args []interface{}) []interface{}
- func (a Int64) GoString() string
- func (a Int64) IsZero() bool
- func (m *Int64) Marshal() (dAtA []byte, err error)
- func (a Int64) MarshalBinary() (data []byte, err error)
- func (a Int64) MarshalJSON() ([]byte, error)
- func (a Int64) MarshalText() ([]byte, error)
- func (m *Int64) MarshalTo(dAtA []byte) (int, error)
- func (m *Int64) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Int64) Ptr() *int64
- func (a *Int64) Reset()
- func (a *Int64) Scan(value interface{}) (err error)
- func (a *Int64) SetPtr(v *int64)
- func (a *Int64) SetValid(n int64)
- func (m Int64) Size() (n int)
- func (a Int64) String() string
- func (m *Int64) Unmarshal(dAtA []byte) error
- func (a *Int64) UnmarshalBinary(data []byte) error
- func (a *Int64) UnmarshalJSON(data []byte) error
- func (a *Int64) UnmarshalText(text []byte) error
- func (a Int64) Value() (driver.Value, error)
- func (a Int64) WriteTo(_ Dialecter, w *bytes.Buffer) (err error)
- type Int8
- func (a Int8) Append(args []interface{}) []interface{}
- func (a Int8) GoString() string
- func (a Int8) IsZero() bool
- func (m *Int8) Marshal() (dAtA []byte, err error)
- func (a Int8) MarshalBinary() (data []byte, err error)
- func (a Int8) MarshalJSON() ([]byte, error)
- func (a Int8) MarshalText() ([]byte, error)
- func (m *Int8) MarshalTo(dAtA []byte) (int, error)
- func (m *Int8) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Int8) Ptr() *int8
- func (a *Int8) Reset()
- func (a *Int8) Scan(value interface{}) (err error)
- func (a *Int8) SetPtr(v *int8)
- func (a *Int8) SetValid(n int8)
- func (m Int8) Size() (n int)
- func (a Int8) String() string
- func (m *Int8) Unmarshal(dAtA []byte) error
- func (a *Int8) UnmarshalBinary(data []byte) error
- func (a *Int8) UnmarshalJSON(data []byte) error
- func (a *Int8) UnmarshalText(text []byte) error
- func (a Int8) Value() (driver.Value, error)
- func (a Int8) WriteTo(_ Dialecter, w *bytes.Buffer) (err error)
- type String
- func (a String) Append(args []interface{}) []interface{}
- func (a String) GoString() string
- func (a String) IsZero() bool
- func (a *String) Marshal() (dAtA []byte, err error)
- func (a String) MarshalBinary() (data []byte, err error)
- func (a String) MarshalJSON() ([]byte, error)
- func (a String) MarshalText() ([]byte, error)
- func (a *String) MarshalTo(dAtA []byte) (int, error)
- func (a *String) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a String) Ptr() *string
- func (a *String) Reset()
- func (a *String) Scan(value interface{}) (err error)
- func (a *String) SetPtr(v *string)
- func (a *String) SetValid(v string)
- func (a String) Size() (n int)
- func (a String) String() string
- func (a *String) Unmarshal(dAtA []byte) error
- func (a *String) UnmarshalBinary(data []byte) error
- func (a *String) UnmarshalJSON(data []byte) error
- func (a *String) UnmarshalText(text []byte) error
- func (a String) Value() (driver.Value, error)
- func (a String) WriteTo(d Dialecter, w *bytes.Buffer) (err error)
- type Time
- func (a Time) Append(args []interface{}) []interface{}
- func (a Time) GoString() string
- func (a *Time) Marshal() (dAtA []byte, err error)
- func (a Time) MarshalBinary() (data []byte, err error)
- func (a Time) MarshalJSON() ([]byte, error)
- func (a Time) MarshalText() ([]byte, error)
- func (a *Time) Proto() *timestamppb.Timestamp
- func (a Time) Ptr() *time.Time
- func (a *Time) Reset()
- func (a *Time) Scan(value interface{}) (err error)
- func (a *Time) SetProto(v *timestamppb.Timestamp)
- func (a *Time) SetPtr(v *time.Time)
- func (a *Time) SetValid(v time.Time)
- func (a Time) String() string
- func (a *Time) Unmarshal(dAtA []byte) error
- func (a *Time) UnmarshalBinary(data []byte) error
- func (a *Time) UnmarshalJSON(data []byte) error
- func (a *Time) UnmarshalText(text []byte) error
- func (a Time) WriteTo(d Dialecter, w *bytes.Buffer) (err error)
- type Uint16
- func (a Uint16) Append(args []interface{}) []interface{}
- func (a Uint16) GoString() string
- func (a Uint16) IsZero() bool
- func (m *Uint16) Marshal() (dAtA []byte, err error)
- func (a Uint16) MarshalBinary() (data []byte, err error)
- func (a Uint16) MarshalJSON() ([]byte, error)
- func (a Uint16) MarshalText() ([]byte, error)
- func (m *Uint16) MarshalTo(dAtA []byte) (int, error)
- func (m *Uint16) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Uint16) Ptr() *uint16
- func (a *Uint16) Reset()
- func (a *Uint16) Scan(value interface{}) (err error)
- func (a *Uint16) SetPtr(v *uint16)
- func (a *Uint16) SetValid(n uint16)
- func (m Uint16) Size() (n int)
- func (a Uint16) String() string
- func (m *Uint16) Unmarshal(dAtA []byte) error
- func (a *Uint16) UnmarshalBinary(data []byte) error
- func (a *Uint16) UnmarshalJSON(data []byte) error
- func (a *Uint16) UnmarshalText(text []byte) (err error)
- func (a Uint16) Value() (driver.Value, error)
- func (a Uint16) WriteTo(_ Dialecter, w *bytes.Buffer) (err error)
- type Uint32
- func (a Uint32) Append(args []interface{}) []interface{}
- func (a Uint32) GoString() string
- func (a Uint32) IsZero() bool
- func (m *Uint32) Marshal() (dAtA []byte, err error)
- func (a Uint32) MarshalBinary() (data []byte, err error)
- func (a Uint32) MarshalJSON() ([]byte, error)
- func (a Uint32) MarshalText() ([]byte, error)
- func (m *Uint32) MarshalTo(dAtA []byte) (int, error)
- func (m *Uint32) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Uint32) Ptr() *uint32
- func (a *Uint32) Reset()
- func (a *Uint32) Scan(value interface{}) (err error)
- func (a *Uint32) SetPtr(v *uint32)
- func (a *Uint32) SetValid(n uint32)
- func (m Uint32) Size() (n int)
- func (a Uint32) String() string
- func (m *Uint32) Unmarshal(dAtA []byte) error
- func (a *Uint32) UnmarshalBinary(data []byte) error
- func (a *Uint32) UnmarshalJSON(data []byte) error
- func (a *Uint32) UnmarshalText(text []byte) (err error)
- func (a Uint32) Value() (driver.Value, error)
- func (a Uint32) WriteTo(_ Dialecter, w *bytes.Buffer) (err error)
- type Uint64
- func (a Uint64) Append(args []interface{}) []interface{}
- func (a Uint64) GoString() string
- func (a Uint64) IsZero() bool
- func (m *Uint64) Marshal() (dAtA []byte, err error)
- func (a Uint64) MarshalBinary() (data []byte, err error)
- func (a Uint64) MarshalJSON() ([]byte, error)
- func (a Uint64) MarshalText() ([]byte, error)
- func (m *Uint64) MarshalTo(dAtA []byte) (int, error)
- func (m *Uint64) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Uint64) Ptr() *uint64
- func (a *Uint64) Reset()
- func (a *Uint64) Scan(value interface{}) (err error)
- func (a *Uint64) SetPtr(v *uint64)
- func (a *Uint64) SetValid(n uint64)
- func (m Uint64) Size() (n int)
- func (a Uint64) String() string
- func (m *Uint64) Unmarshal(dAtA []byte) error
- func (a *Uint64) UnmarshalBinary(data []byte) error
- func (a *Uint64) UnmarshalJSON(data []byte) error
- func (a *Uint64) UnmarshalText(text []byte) (err error)
- func (a Uint64) Value() (driver.Value, error)
- func (a Uint64) WriteTo(_ Dialecter, w *bytes.Buffer) (err error)
- type Uint8
- func (a Uint8) Append(args []interface{}) []interface{}
- func (a Uint8) GoString() string
- func (a Uint8) IsZero() bool
- func (a *Uint8) Marshal() (dAtA []byte, err error)
- func (a Uint8) MarshalBinary() (data []byte, err error)
- func (a Uint8) MarshalJSON() ([]byte, error)
- func (a Uint8) MarshalText() ([]byte, error)
- func (a *Uint8) MarshalTo(dAtA []byte) (int, error)
- func (a *Uint8) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Uint8) Ptr() *uint8
- func (a *Uint8) Reset()
- func (a *Uint8) Scan(value interface{}) (err error)
- func (a *Uint8) SetPtr(v *uint8)
- func (a *Uint8) SetValid(n uint8)
- func (a Uint8) Size() (n int)
- func (a Uint8) String() string
- func (a *Uint8) Unmarshal(dAtA []byte) error
- func (a *Uint8) UnmarshalBinary(data []byte) error
- func (a *Uint8) UnmarshalJSON(data []byte) error
- func (a *Uint8) UnmarshalText(text []byte) (err error)
- func (a Uint8) Value() (driver.Value, error)
- func (a Uint8) WriteTo(_ Dialecter, w *bytes.Buffer) (err error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthNull = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowNull = fmt.Errorf("proto: integer overflow") )
var AllTypes = [...]interface{}{Bool{}, Decimal{}, Float64{}, Int8{}, Int16{}, Int32{}, Int64{}, String{}, Time{}, Uint8{}, Uint16{}, Uint32{}, Uint64{}}
AllTypes contains value objects of all types in this package. The array might change in size in the future. The types are useful for functions like: gopkg.in/go-playground/validator.v9/Validate.RegisterCustomTypeFunc or gob.Register.
Functions ¶
This section is empty.
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. Bool implements interface Argument.
func MakeBoolFromByte ¶
MakeBoolFromByte makes a new Bool from a (text) byte slice.
func (Bool) Append ¶
func (a Bool) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
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) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
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) Reset ¶
func (a *Bool) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Bool) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
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.Bool.
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 Decimal ¶
type Decimal struct { PrecisionStr string // Not empty if to large for an uint64 Precision uint64 // The value itself, always set if it fits into an uint64 Scale int32 // Number of digits after the dot Negative bool Valid bool // Quote if true JSON marshaling will quote the returned number and creates // a string. JavaScript floats are only 53 bits. Quote bool // contains filtered or unexported fields }
Decimal defines a container type for any MySQL/MariaDB decimal/numeric/float/double data type and their representation in Go. It can store arbitrary large values. Decimal does not perform any kind of calculations. Helpful packages for arbitrary precision calculations are github.com/ericlagergren/decimal or github.com/shopspring/decimal or a future new Go type. https://github.com/bojanz/currency https://dev.mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html https://dev.mysql.com/doc/refman/5.7/en/floating-point-types.html
func MakeDecimalBytes ¶
MakeDecimalBytes parses b to create a new Decimal. b must contain ASCII numbers. If b contains null/NULL the returned object represents that value. This function can be used for big.Int.Bytes() or similar implementations. Parses only numbers as stored in MySQL/MariaDB decimal/double column format, e.g. -47.11.
func MakeDecimalFloat64 ¶
MakeDecimalFloat64 converts a float64 to Decimal.
Example:
MakeDecimalFloat64(123.45678901234567).String() // output: "123.45678901234567" MakeDecimalFloat64(123.456789012345678).String() // output: "123.45678901234568" MakeDecimalFloat64(.00000000000000001).String() // output: "0.00000000000000001"
func MakeDecimalInt64 ¶
MakeDecimalInt64 converts an int64 with the scale to a Decimal.
func MustMakeDecimalBytes ¶
MustMakeDecimalBytes same behaviour as MakeDecimalBytes but panics on error.
func (Decimal) Equal ¶
Equal compares another Decimal object for equality. Equality can only succeed when both `Valid` fields are true.
func (*Decimal) Fake ¶
Fake implements pseudo.Faker interface to generate custom fake data for specific fields. In this case field PrecisionStr should not contain random fake data at all or we need to generate correct fake data.
func (Decimal) Float64 ¶
Float64 converts the precision and the scale to a float64 value including the usual float behaviour. Overflow will result in an undefined float64.
func (Decimal) GoString ¶
GoString returns an optimized version of the Go representation of Decimal.
func (Decimal) Int64 ¶
Int64 converts the underlying uint64 to an int64. Very useful for creating a new 3rd party package type/object. If the Precision field overflows math.MaxInt64 the return values are 0,0. If you want to aovid this use the String function and create the 3rd party type via the string.
func (Decimal) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Decimal) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Decimal) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for XML serialization. Does not support quoting. An invalid type returns an empty string.
func (*Decimal) MarshalToSizedBuffer ¶
func (*Decimal) Reset ¶
func (d *Decimal) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Decimal) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign.
func (Decimal) String ¶
String returns the string representation of the fixed with decimal. Returns the word `NULL` if the current value is not valid, for now.
func (*Decimal) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. As a string representation is already used when encoding to text, this method stores that string as []byte
func (*Decimal) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (*Decimal) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for XML deserialization.
type Dialecter ¶
type Dialecter interface { EscapeIdent(w *bytes.Buffer, ident string) EscapeBool(w *bytes.Buffer, b bool) EscapeString(w *bytes.Buffer, s string) EscapeTime(w *bytes.Buffer, t time.Time) EscapeBinary(w *bytes.Buffer, b []byte) }
Dialecter at an interface that wraps the diverse properties of individual SQL drivers.
type Float64 ¶
Float64 is a nullable float64. It does not consider zero values to be null. It will decode to null, not zero, if null.
func MakeFloat64 ¶
MakeFloat64 creates a new Float64. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Float64 implements interface Argument.
func MakeFloat64FromByte ¶
MakeFloat64FromByte makes a new Float64 from a (text) byte slice.
func (Float64) Append ¶
func (a Float64) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Float64) IsZero ¶
IsZero returns true for invalid Float64s, for future omitempty support (Go 1.4?) A non-null Float64 with a 0 value will not be considered zero.
func (Float64) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Float64) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Float64 is null.
func (Float64) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Float64 is null.
func (*Float64) MarshalToSizedBuffer ¶
func (Float64) Ptr ¶
Ptr returns a pointer to this Float64's value, or a nil pointer if this Float64 is null.
func (*Float64) Reset ¶
func (a *Float64) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Float64) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign.
func (*Float64) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Float64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Float64. It also supports unmarshalling a sql.Float64.
func (*Float64) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Float64 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 Int16 ¶
Int16 is a nullable int16. It does not consider zero values to be null. It will decode to null, not zero, if null. Int16 implements interface Argument.
func MakeInt16 ¶
MakeInt16 creates a new Int16. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Int16 implements interface Argument.
func MakeInt16FromByte ¶
MakeInt16FromByte makes a new Int16 from a (text) byte slice.
func (Int16) Append ¶
func (a Int16) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Int16) IsZero ¶
IsZero returns true for invalid Int16's, for future omitempty support (Go 1.4?) A non-null Int16 with a 0 value will not be considered zero.
func (Int16) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Int16) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Int16 is null.
func (Int16) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Int16 is null.
func (Int16) Ptr ¶
Ptr returns a pointer to this Int16's value, or a nil pointer if this Int16 is null.
func (*Int16) Reset ¶
func (a *Int16) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Int16) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign.
func (*Int16) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Int16) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Int16. It also supports unmarshalling a sql.Int16.
func (*Int16) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int16 if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or sqlStrNullLC.
type Int32 ¶
Int32 is a nullable int32. It does not consider zero values to be null. It will decode to null, not zero, if null. Int32 implements interface Argument.
func MakeInt32 ¶
MakeInt32 creates a new Int32. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Int32 implements interface Argument.
func MakeInt32FromByte ¶
MakeInt32FromByte makes a new Int32 from a (text) byte slice.
func (Int32) Append ¶
func (a Int32) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Int32) IsZero ¶
IsZero returns true for invalid Int32's, for future omitempty support (Go 1.4?) A non-null Int32 with a 0 value will not be considered zero.
func (Int32) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
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) Ptr ¶
Ptr returns a pointer to this Int32's value, or a nil pointer if this Int32 is null.
func (*Int32) Reset ¶
func (a *Int32) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Int32) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign.
func (*Int32) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
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.Int32.
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 sqlStrNullLC.
type Int64 ¶
Int64 is a nullable int64. It does not consider zero values to be null. It will decode to null, not zero, if null. Int64 implements interface Argument.
func MakeInt64 ¶
MakeInt64 creates a new Int64. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Int64 implements interface Argument.
func MakeInt64FromByte ¶
MakeInt64FromByte makes a new Int64 from a (text) byte slice.
func (Int64) Append ¶
func (a Int64) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Int64) IsZero ¶
IsZero returns true for invalid Int64's, for future omitempty support (Go 1.4?) A non-null Int64 with a 0 value will not be considered zero.
func (Int64) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
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) Reset ¶
func (a *Int64) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Int64) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign.
func (*Int64) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
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.Int64.
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 sqlStrNullLC.
type Int8 ¶
Int8 is a nullable int8. It does not consider zero values to be null. It will decode to null, not zero, if null. Int8 implements interface Argument.
func MakeInt8 ¶
MakeInt8 creates a new Int8. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Int8 implements interface Argument.
func MakeInt8FromByte ¶
MakeInt8FromByte makes a new Int8 from a (text) byte slice.
func (Int8) Append ¶
func (a Int8) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Int8) IsZero ¶
IsZero returns true for invalid Int8's, for future omitempty support (Go 1.4?) A non-null Int8 with a 0 value will not be considered zero.
func (Int8) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Int8) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Int8 is null.
func (Int8) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Int8 is null.
func (Int8) Ptr ¶
Ptr returns a pointer to this Int8's value, or a nil pointer if this Int8 is null.
func (*Int8) Reset ¶
func (a *Int8) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Int8) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign.
func (*Int8) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Int8) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Int8. It also supports unmarshalling a sql.Int8.
func (*Int8) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Int8 if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or sqlStrNullLC.
type String ¶
type String struct { // Data should be called String but there is String() method or should be // called Value but there is a Value() method. Now it's called Data because // there is no Data() method. Calling it Str would be weird... Data string Valid bool // Valid is true if String is not NULL }
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. String implements interface Argument.
func MakeString ¶
MakeString creates a new String. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. String implements interface Argument.
func (String) Append ¶
func (a String) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (String) GoString ¶
GoString prints an optimized Go representation. Takes are of backticks. Looses the information of the private operator. That might get fixed.
func (String) IsZero ¶
IsZero returns true for null strings, for potential future omitempty support.
func (String) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
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) MarshalToSizedBuffer ¶
func (String) Ptr ¶
Ptr returns a pointer to this String's value, or a nil pointer if this String is null.
func (*String) Reset ¶
func (a *String) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*String) Scan ¶
Scan implements the Scanner interface. Approx. >2x times faster than database/sql.convertAssign.
func (*String) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
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.String.
func (*String) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null String if the input is a blank string.
type Time ¶
Time represents a time.Time that may be NULL. Time implements the Scanner interface so it can be used as a scan destination:
var nt Time err := db.QueryRow("SELECT time FROM foo WHERE id=?", id).Scan(&nt) ... if nt.Valid { // use nt.Time } else { // NULL value }
This Time implementation is not driver-specific
func MakeTime ¶
MakeTime creates a new Time. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Time implements interface Argument.
func ParseDateTime ¶
ParseDateTime parses a string into a Time type. Empty string is considered NULL.
func (Time) Append ¶
func (a Time) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Time) MarshalBinary ¶
MarshalBinary transforms the time type into a byte slice.
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this time is null.
func (Time) MarshalText ¶
MarshalText transforms the time type into a byte slice.
func (*Time) Proto ¶
func (a *Time) Proto() *timestamppb.Timestamp
func (Time) Ptr ¶
Ptr returns a pointer to this Time's value, or a nil pointer if this Time is null.
func (*Time) Reset ¶
func (a *Time) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Time) Scan ¶
Scan implements the Scanner interface. The value type must be time.Time or string / []byte (formatted time-string), otherwise Scan fails. It supports more input data than database/sql.NullTime.Scan
func (*Time) SetProto ¶
func (a *Time) SetProto(v *timestamppb.Timestamp)
func (*Time) UnmarshalBinary ¶
UnmarshalBinary parses the byte slice to create a time type.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string, object (e.g. pq.Time and friends) and null input.
func (*Time) UnmarshalText ¶
UnmarshalText parses the byte slice to create a time type.
type Uint16 ¶
Uint16 is a nullable int16. It does not consider zero values to be null. It will decode to null, not zero, if null. Uint16 implements interface Argument.
func MakeUint16 ¶
MakeUint16 creates a new Uint16. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Uint16 implements interface Argument.
func MakeUint16FromByte ¶
MakeUint16FromByte makes a new Uint16 from a (text) byte slice.
func (Uint16) Append ¶
func (a Uint16) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Uint16) IsZero ¶
IsZero returns true for invalid Uint16's, for future omitempty support (Go 1.4?) A non-null Uint16 with a 0 value will not be considered zero.
func (Uint16) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Uint16) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Uint16 is null.
func (Uint16) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Uint16 is null.
func (*Uint16) MarshalToSizedBuffer ¶
func (Uint16) Ptr ¶
Ptr returns a pointer to this Uint16's value, or a nil pointer if this Uint16 is null.
func (*Uint16) Reset ¶
func (a *Uint16) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Uint16) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign
func (*Uint16) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Uint16) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Uint16. It also supports unmarshalling a sql.Uint16.
func (*Uint16) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Uint16 if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or sqlStrNullLC.
type Uint32 ¶
Uint32 is a nullable int32. It does not consider zero values to be null. It will decode to null, not zero, if null. Uint32 implements interface Argument.
func MakeUint32 ¶
MakeUint32 creates a new Uint32. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Uint32 implements interface Argument.
func MakeUint32FromByte ¶
MakeUint32FromByte makes a new Uint32 from a (text) byte slice.
func (Uint32) Append ¶
func (a Uint32) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Uint32) IsZero ¶
IsZero returns true for invalid Uint32's, for future omitempty support (Go 1.4?) A non-null Uint32 with a 0 value will not be considered zero.
func (Uint32) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Uint32) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Uint32 is null.
func (Uint32) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Uint32 is null.
func (*Uint32) MarshalToSizedBuffer ¶
func (Uint32) Ptr ¶
Ptr returns a pointer to this Uint32's value, or a nil pointer if this Uint32 is null.
func (*Uint32) Reset ¶
func (a *Uint32) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Uint32) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign
func (*Uint32) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Uint32) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Uint32. It also supports unmarshalling a sql.Uint32.
func (*Uint32) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Uint32 if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or sqlStrNullLC.
type Uint64 ¶
Uint64 is a nullable int64. It does not consider zero values to be null. It will decode to null, not zero, if null. Uint64 implements interface Argument.
func MakeUint64 ¶
MakeUint64 creates a new Uint64. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Uint64 implements interface Argument.
func MakeUint64FromByte ¶
MakeUint64FromByte makes a new Uint64 from a (text) byte slice.
func (Uint64) Append ¶
func (a Uint64) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Uint64) IsZero ¶
IsZero returns true for invalid Uint64's, for future omitempty support (Go 1.4?) A non-null Uint64 with a 0 value will not be considered zero.
func (Uint64) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Uint64) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Uint64 is null.
func (Uint64) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Uint64 is null.
func (*Uint64) MarshalToSizedBuffer ¶
func (Uint64) Ptr ¶
Ptr returns a pointer to this Uint64's value, or a nil pointer if this Uint64 is null.
func (*Uint64) Reset ¶
func (a *Uint64) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Uint64) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign
func (*Uint64) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Uint64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Uint64. It also supports unmarshalling a sql.Uint64.
func (*Uint64) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Uint64 if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or sqlStrNullLC.
type Uint8 ¶
Uint8 is a nullable int8. It does not consider zero values to be null. It will decode to null, not zero, if null. Uint8 implements interface Argument.
func MakeUint8 ¶
MakeUint8 creates a new Uint8. Setting the second optional argument to false, the string will not be valid anymore, hence NULL. Uint8 implements interface Argument.
func MakeUint8FromByte ¶
MakeUint8FromByte makes a new Uint8 from a (text) byte slice.
func (Uint8) Append ¶
func (a Uint8) Append(args []interface{}) []interface{}
Append appends the value or its nil type to the interface slice.
func (Uint8) IsZero ¶
IsZero returns true for invalid Uint8's, for future omitempty support (Go 1.4?) A non-null Uint8 with a 0 value will not be considered zero.
func (Uint8) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Uint8) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this Uint8 is null.
func (Uint8) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Uint8 is null.
func (Uint8) Ptr ¶
Ptr returns a pointer to this Uint8's value, or a nil pointer if this Uint8 is null.
func (*Uint8) Reset ¶
func (a *Uint8) Reset()
Reset sets the value to Go's default value and Valid to false.
func (*Uint8) Scan ¶
Scan implements the Scanner interface. Approx. >3x times faster than database/sql.convertAssign
func (*Uint8) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Uint8) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Uint8. It also supports unmarshalling a sql.Uint8.
func (*Uint8) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Uint8 if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or sqlStrNullLC.