reasonable handling of nullable values
github.com/guregu/null/v5
gopkg.in
path.database/sql
: Int32, Int16, Byte
Value[T]
embedding sql.Null[T]
zero.Value[T]
requires that T
is comparable
. null.Value[T]
supports any value.Behavior from v4 is unchanged, so it should be an easy upgrade. Thank you and enjoy.
Full Changelog: https://github.com/guregu/null/compare/v4.0.0...v5.0.0
This is a new major release that improves performance and fixes an inconsistency that existed in v3.
null.Time
and zero.Time
now embed sql.NullTime
.null.Time
and zero.Time
's UnmarshalText
returns a blank string if invalid, making them consistent with the rest of the package (see #47).sql.NullXXX
objects (ex. {"Int64": 123, "Valid": true}
) has been dropped, significantly improving unmarshaling time and reducing allocations.Valid
. Always check for errors.Support for Equal
was added in the previous release.
This release adds an Equal
method to all types, for easy equality checks.
It also adds ValueOrZero
to the zero
package.
Types in the null
package are considered Equal if they're either both invalid, or both valid and have the same value.
Types on the zero
package are considered Equal if their ValueOrZero
is the same, so an invalid string and a valid ""
are equal.
This will be the last release before v4.
Adds IsZero
methods for Time in line with the rest of the types.
Added a new method ValueOrZero
to every type in the null package. This method returns the inner value if valid, or the zero value if invalid (similar to the zero package). See #17.
If you try to JSON marshal Infinity or NaN, you'll get *encoding/json.UnsupportedValueError
. This brings us in line with the standard library.
Int
and Float
can now be read from JSON strings. #23
MarshalText was missing from null.String, but no longer!
This version updates the GoDoc to be consistent with the changes described in #10 and #14.
Blank string input now produces a null null.String
. Now the null
package is consistent. Please use the zero.String
type or v2 if you would like the old behavior.
Fixes #10.