{"modulePath":"github.com/volatiletech/null","version":"v3.0.1+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package zero\n\nPackage 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.\n\n## Types\n\n```go\ntype Bool struct {\n\tsql.NullBool\n}\n```\nBool is a nullable bool. False input is considered null. JSON marshals to false if null. Considered null to SQL unmarshaled from a false value.\n\n```go\nfunc BoolFrom(b bool) Bool\n```\nBoolFrom creates a new Bool that will be null if false.\n\n```go\nfunc BoolFromPtr(b *bool) Bool\n```\nBoolFromPtr creates a new Bool that be null if b is nil.\n\n```go\nfunc NewBool(b bool, valid bool) Bool\n```\nNewBool creates a new Bool\n\n```go\nfunc (b Bool) IsZero() bool\n```\nIsZero returns true for null or zero Bools, for future omitempty support (Go 1.4?)\n\n```go\nfunc (b Bool) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements json.Marshaler. It will encode null if this Bool is null.\n\n```go\nfunc (b Bool) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler. It will encode a zero if this Bool is null.\n\n```go\nfunc (b Bool) Ptr() *bool\n```\nPtr returns a poBooler to this Bool's value, or a nil poBooler if this Bool is null.\n\n```go\nfunc (b *Bool) SetValid(v bool)\n```\nSetValid changes this Bool's value and also sets it to be non-null.\n\n```go\nfunc (b *Bool) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler. \"false\" will be considered a null Bool. It also supports unmarshalling a sql.NullBool.\n\n```go\nfunc (b *Bool) UnmarshalText(text []byte) error\n```\nUnmarshalText 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\".\n\n```go\ntype Float struct {\n\tsql.NullFloat64\n}\n```\nFloat is a nullable float64. Zero input will be considered null. JSON marshals to zero if null. Considered null to SQL if zero.\n\n```go\nfunc FloatFrom(f float64) Float\n```\nFloatFrom creates a new Float that will be null if zero.\n\n```go\nfunc FloatFromPtr(f *float64) Float\n```\nFloatFromPtr creates a new Float that be null if f is nil.\n\n```go\nfunc NewFloat(f float64, valid bool) Float\n```\nNewFloat creates a new Float\n\n```go\nfunc (f Float) IsZero() bool\n```\nIsZero returns true for null or zero Floats, for future omitempty support (Go 1.4?)\n\n```go\nfunc (f Float) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements json.Marshaler. It will encode null if this Float is null.\n\n```go\nfunc (f Float) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler. It will encode a zero if this Float is null.\n\n```go\nfunc (f Float) Ptr() *float64\n```\nPtr returns a poFloater to this Float's value, or a nil poFloater if this Float is null.\n\n```go\nfunc (f *Float) SetValid(v float64)\n```\nSetValid changes this Float's value and also sets it to be non-null.\n\n```go\nfunc (f *Float) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Float. It also supports unmarshalling a sql.NullFloat64.\n\n```go\nfunc (f *Float) UnmarshalText(text []byte) error\n```\nUnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Float 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\".\n\n```go\ntype Int struct {\n\tsql.NullInt64\n}\n```\nInt is a nullable int64. JSON marshals to zero if null. Considered null to SQL if zero.\n\n```go\nfunc IntFrom(i int64) Int\n```\nIntFrom creates a new Int that will be null if zero.\n\n```go\nfunc IntFromPtr(i *int64) Int\n```\nIntFromPtr creates a new Int that be null if i is nil.\n\n```go\nfunc NewInt(i int64, valid bool) Int\n```\nNewInt creates a new Int\n\n```go\nfunc (i Int) IsZero() bool\n```\nIsZero returns true for null or zero Ints, for future omitempty support (Go 1.4?)\n\n```go\nfunc (i Int) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements json.Marshaler. It will encode 0 if this Int is null.\n\n```go\nfunc (i Int) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler. It will encode a zero if this Int is null.\n\n```go\nfunc (i Int) Ptr() *int64\n```\nPtr returns a pointer to this Int's value, or a nil pointer if this Int is null.\n\n```go\nfunc (i *Int) SetValid(n int64)\n```\nSetValid changes this Int's value and also sets it to be non-null.\n\n```go\nfunc (i *Int) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will be considered a null Int. It also supports unmarshalling a sql.NullInt64.\n\n```go\nfunc (i *Int) UnmarshalText(text []byte) error\n```\nUnmarshalText 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\".\n\n```go\ntype String struct {\n\tsql.NullString\n}\n```\nString is a nullable string. JSON marshals to a blank string if null. Considered null to SQL if zero.\n\n```go\nfunc NewString(s string, valid bool) String\n```\nNewString creates a new String\n\n```go\nfunc StringFrom(s string) String\n```\nStringFrom creates a new String that will be null if s is blank.\n\n```go\nfunc StringFromPtr(s *string) String\n```\nStringFromPtr creates a new String that be null if s is nil or blank. It will make s point to the String's value.\n\n```go\nfunc (s String) IsZero() bool\n```\nIsZero returns true for null or empty strings, for potential future omitempty support.\n\n```go\nfunc (s String) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler. It will encode a blank string when this String is null.\n\n```go\nfunc (s String) Ptr() *string\n```\nPtr returns a pointer to this String's value, or a nil pointer if this String is null.\n\n```go\nfunc (s *String) SetValid(v string)\n```\nSetValid changes this String's value and also sets it to be non-null.\n\n```go\nfunc (s *String) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler. It supports string and null input. Blank string input produces a null String. It also supports unmarshalling a sql.NullString.\n\n```go\nfunc (s *String) UnmarshalText(text []byte) error\n```\nUnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null String if the input is a blank string.\n\n```go\ntype Time struct {\n\tTime  time.Time\n\tValid bool\n}\n```\nTime is a nullable time.Time. JSON marshals to the zero value for time.Time if null. Considered to be null to SQL if zero.\n\n```go\nfunc NewTime(t time.Time, valid bool) Time\n```\nNewTime creates a new Time.\n\n```go\nfunc TimeFrom(t time.Time) Time\n```\nTimeFrom creates a new Time that will be null if t is the zero value.\n\n```go\nfunc TimeFromPtr(t *time.Time) Time\n```\nTimeFromPtr creates a new Time that will be null if t is nil or \\*t is the zero value.\n\n```go\nfunc (t Time) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements json.Marshaler. It will encode the zero value of time.Time if this time is invalid.\n\n```go\nfunc (t Time) MarshalText() ([]byte, error)\n```\n\n```go\nfunc (t Time) Ptr() *time.Time\n```\nPtr returns a pointer to this Time's value, or a nil pointer if this Time is zero.\n\n```go\nfunc (t *Time) Scan(value interface{}) error\n```\nScan implements Scanner interface.\n\n```go\nfunc (t *Time) SetValid(v time.Time)\n```\nSetValid changes this Time's value and sets it to be non-null.\n\n```go\nfunc (t *Time) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler. It supports string, object (e.g. pq.NullTime and friends) and null input.\n\n```go\nfunc (t *Time) UnmarshalText(text []byte) error\n```\n\n```go\nfunc (t Time) Value() (driver.Value, error)\n```\nValue implements the driver Valuer interface.\n\n","path":"github.com/volatiletech/null/zero","name":"zero","synopsis":"Package zero contains SQL types that consider zero input and null input to be equivalent with convenient support for JSON and text marshaling.","isRedistributable":true}
