types - ActiveState ActiveGo 1.8
...

Package types

import "go4.org/types"
Overview
Index

Overview ▾

Package types provides various common types.

Variables

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

var EmptyBody io.ReadCloser = ioutil.NopCloser(strings.NewReader(""))

NopCloser is an io.Closer that does nothing.

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

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

ByTime sorts times.

type ByTime []time.Time

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

CloseFunc implements io.Closer with a function.

type CloseFunc func() error

func (CloseFunc) Close

func (fn CloseFunc) Close() error

type Time3339

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

type Time3339 time.Time

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

IsZero 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