types

package
v0.0.0-...-3814ceb Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NullDecoder

func NullDecoder(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error)

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.

func ParseExtendedDuration

func ParseExtendedDuration(data string) (result time.Duration, err error)

ParseExtendedDuration is a helper function that allows for string duration values containing days.

Types

type Duration

type Duration time.Duration

Duration is an alias for time.Duration that de/serialises to JSON as human-readable strings.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of d

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON data to Duration

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(data []byte) error

UnmarshalText converts text data to Duration

type NullDuration

type NullDuration struct {
	Duration
	Valid bool
}

NullDuration is a nullable Duration, in the same vein as the nullable types provided by package gopkg.in/guregu/null.v3.

func NewNullDuration

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

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.

Jump to

Keyboard shortcuts

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