rate

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  Rate = 1
	KB      = 1024 * B
	MB      = 1024 * KB
	GB      = 1024 * MB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Rate

type Rate int64

Rate wraps int64. It is used to parse the custom rate format from YAML and JSON. This type should not propagate beyond the scope of input/output processing.

func ParseRate

func ParseRate(rateStr string) (Rate, error)

ParseRate parses a string into a int64.

func (Rate) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

func (Rate) MarshalYAML

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

MarshalYAML implements the yaml.Marshaler interface.

func (*Rate) Set

func (d *Rate) Set(s string) error

Set implements pflag/flag.Value

func (Rate) String

func (d Rate) String() string

String returns the rate with an uppercase unit.

func (*Rate) Type

func (d *Rate) Type() string

Type implements pflag.Value

func (*Rate) UnmarshalJSON

func (d *Rate) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Rate) UnmarshalYAML

func (d *Rate) 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