Documentation
¶
Overview ¶
Package unit implements parsing for string values with units.
Index ¶
Constants ¶
Variables ¶
var DefaultUnits = map[string]int64{ "B": 1, "K": K, "M": M, "G": G, "T": T, "P": P, "E": E, "kB": 1000, "KB": 1000, "MB": 1000 * 1000, "GB": 1000 * 1000 * 1000, "TB": 1000 * 1000 * 1000 * 1000, "PB": 1000 * 1000 * 1000 * 1000 * 1000, "EB": 1000 * 1000 * 1000 * 1000 * 1000 * 1000, }
DefaultUnits is the default unit mapping as used by many standard cli-tools.
Functions ¶
This section is empty.
Types ¶
type Unit ¶
type Unit struct {
// contains filtered or unexported fields
}
Unit is a map of unit names to conversion multipliers.
There must be a unit that maps to 1.
func MustNewUnit ¶
MustNewUnit is like NewUnit but panics if the mapping 'm' is not valid.
func NewUnit ¶
NewUnit returns a new Unit given a mapping 'm'.
func (*Unit) MustNewValue ¶
MustNewValue is like NewValue but panics if the new Value could not be generated.
func (*Unit) NewValue ¶
NewValue returns a Value based on a Unit. It's value is set to "value". "value" is the initial value, an explicit sign can be set, but is usually "None".
type Value ¶
type Value struct {
// value is the integer value.
Value int64
// sign is the explicit sign given by the string converted to the
// integer.
ExplicitSign Sign
// set to false if this is the default value, true if the the option was given
IsSet bool
// contains filtered or unexported fields
}
Value is any value that can be represented by a unit.
Value implements flag.Value and flag.Getter.
func (Value) String ¶
String implements flag.Value.String and fmt.Stringer.
Source Files
¶
- unit.go