humanize

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
	TiByte
	PiByte
	EiByte
)

IEC Sizes. kibis of bits

Variables

This section is empty.

Functions

This section is empty.

Types

type Bytes

type Bytes int64

func ParseBytes

func ParseBytes(bytesStr string) (Bytes, error)

ParseBytes parses a string into a Bytes

func (Bytes) MarshalJSON

func (b Bytes) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Bytes) MarshalText

func (b *Bytes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (Bytes) MarshalYAML

func (b Bytes) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (Bytes) String

func (b Bytes) String() string

func (*Bytes) UnmarshalJSON

func (b *Bytes) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Bytes) UnmarshalText

func (b *Bytes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (*Bytes) UnmarshalYAML

func (b *Bytes) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Duration

type Duration time.Duration

Duration wraps time.Duration. It is used to parse the custom duration format from YAML. This type should not propagate beyond the scope of input/output processing.

func ParseDuration

func ParseDuration(durationStr string) (Duration, error)

ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.

func (Duration) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

func (*Duration) MarshalText

func (d *Duration) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalJSON

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

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Duration) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

Jump to

Keyboard shortcuts

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