Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NullDecoder ¶ added in v0.22.0
NullDecoder converts data with expected type f to a guregu/null value of equivalent type t. It returns an error if a type mismatch occurs.
Types ¶
type Duration ¶
Duration is an alias for time.Duration that de/serialises to JSON as human-readable strings.
func (Duration) MarshalJSON ¶
MarshalJSON returns the JSON representation of d
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON converts JSON data to Duration
func (*Duration) UnmarshalText ¶
UnmarshalText converts text data to Duration
type NullDuration ¶
NullDuration is a nullable Duration, in the same vein as the nullable types provided by package gopkg.in/guregu/null.v3.
func NewNullDuration ¶ added in v0.21.0
func NewNullDuration(d time.Duration, valid bool) NullDuration
NewNullDuration is a simple helper constructor function
func NullDurationFrom ¶
func NullDurationFrom(d time.Duration) NullDuration
NullDurationFrom returns a new valid NullDuration from a time.Duration.
func (NullDuration) MarshalJSON ¶
func (d NullDuration) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of d
func (*NullDuration) UnmarshalJSON ¶
func (d *NullDuration) UnmarshalJSON(data []byte) error
UnmarshalJSON converts JSON data to a valid NullDuration
func (*NullDuration) UnmarshalText ¶
func (d *NullDuration) UnmarshalText(data []byte) error
UnmarshalText converts text data to a valid NullDuration
func (NullDuration) ValueOrZero ¶ added in v0.26.0
func (d NullDuration) ValueOrZero() Duration
ValueOrZero returns the underlying Duration value of d if valid or its zero equivalent otherwise. It matches the existing guregu/null API.