Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Binary = Humaner{ // contains filtered or unexported fields }
Binary is a Humaner representing power-of-1024 based prefixes, typically used for bytes.
var Metric = Humaner{ // contains filtered or unexported fields }
Metric is a Humaner representing metric prefixes.
Functions ¶
This section is empty.
Types ¶
type Count32 ¶
type Count32 uint32
Count32 is a count of something, capped at math.MaxUint32.
func NewCount32 ¶
NewCount32 initializes a Count32 from a uint64, capped at math.MaxUint32.
func (*Count32) AdjustMaxIfNecessary ¶
AdjustMaxIfNecessary adjusts `*n1` to be `max(*n1, n2)`. Return true iff `n2` was greater than `*n1`.
func (*Count32) AdjustMaxIfPossible ¶
AdjustMaxIfPossible adjusts `*n1` to be `max(*n1, n2)`. Return true iff `n2` was greater than or equal to `*n1`.
type Count64 ¶
type Count64 uint64
Count64 is a count of something, capped at math.MaxUint64.
func (*Count64) AdjustMaxIfNecessary ¶
AdjustMaxIfNecessary adjusts `*n1` to be `max(*n1, n2)`. Return true iff `n2` was greater than `*n1`.
func (*Count64) AdjustMaxIfPossible ¶
AdjustMaxIfPossible adjusts `*n1` to be `max(*n1, n2)`. Return true iff `n2` was greater than or equal to `*n1`.
type Humanable ¶ added in v1.3.0
type Humanable interface { // ToUint64 returns the value as a uint64, and a boolean telling // whether it overflowed. ToUint64() (uint64, bool) }
Humanable is a quantity that can be made human-readable using `Humaner.Format()`.
type Humaner ¶
type Humaner struct {
// contains filtered or unexported fields
}
Humaner is an object that can format a Humanable in human-readable format.
func (*Humaner) Format ¶ added in v1.3.0
Format formats values, aligned, in `len(unit) + 10` or fewer characters (except for extremely large numbers). It returns strings representing the numeral and the unit string.
func (*Humaner) FormatNumber ¶ added in v1.3.0
FormatNumber formats n, aligned, in `len(unit) + 10` or fewer characters (except for extremely large numbers). It returns strings representing the numeral and the unit string.