v0.0.0-...-2148625 Latest Latest

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

Go to latest
Published: Feb 25, 2023 License: Apache-2.0 Imports: 8 Imported by: 78



Package types provides various common types.



This section is empty.


EmptyBody is a ReadCloser that returns EOF on Read and does nothing on Close.

View Source
var NopCloser io.Closer = CloseFunc(func() error { return nil })

NopCloser is an io.Closer that does nothing.


func NewOnceCloser

func NewOnceCloser(c io.Closer) io.Closer

NewOnceCloser returns a Closer wrapping c which only calls Close on c once. Subsequent calls to Close return nil.


type ByTime

type ByTime []time.Time

ByTime sorts times.

func (ByTime) Len

func (s ByTime) Len() int

func (ByTime) Less

func (s ByTime) Less(i, j int) bool

func (ByTime) Swap

func (s ByTime) Swap(i, j int)

type CloseFunc

type CloseFunc func() error

CloseFunc implements io.Closer with a function.

func (CloseFunc) Close

func (fn CloseFunc) Close() error

type Time3339

type Time3339 time.Time

Time3339 is a time.Time which encodes to and from JSON as an RFC 3339 time in UTC.

func ParseTime3339OrNil

func ParseTime3339OrNil(v string) *Time3339

func ParseTime3339OrZero

func ParseTime3339OrZero(v string) Time3339

ParseTime3339OrZero parses a string in RFC3339 format. If it's invalid, the zero time value is returned instead.

func (*Time3339) IsAnyZero

func (t *Time3339) IsAnyZero() bool

IsAnyZero returns whether the time is Go zero or Unix zero.

func (Time3339) MarshalJSON

func (t Time3339) MarshalJSON() ([]byte, error)

func (Time3339) String

func (t Time3339) String() string

func (Time3339) Time

func (t Time3339) Time() time.Time

Time returns the time as a time.Time with slightly less stutter than a manual conversion.

func (*Time3339) UnmarshalJSON

func (t *Time3339) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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