types

package
v0.0.0-...-c77d5a7 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: MIT, AGPL-3.0 Imports: 6 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.

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