Documentation ¶
Index ¶
Constants ¶
const ExponentialFold = 2
ExponentialFold defines the value to fold back to the previous exponent for better display of a small value.
const IECBase = 1024
IECBase is the exponential base for IEC units.
const SIBase = 1000
SIBase is the exponential base for SI units.
Variables ¶
var ByteIECUnits = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB"}
ByteIECUnits lists known units we can convert to based on uint64.
See https://en.wikipedia.org/wiki/Byte#Unit_symbol
var ByteSIUnits = []string{"B", "KB", "MB", "GB", "TB", "PB"}
ByteSIUnits lists known units we can convert to based on uint64.
Functions ¶
This section is empty.
Types ¶
type ByteAny ¶ added in v0.3.0
func ParseBytes ¶
ParseBytes parses a strings and returns the proper ByteAny implementation based on the unit specified.
When a plain value or B unit is used, ByteIEC is returned.
type BytesIEC ¶ added in v0.3.0
type BytesIEC uint64
BytesIEC is the IEC (1024) unit implementation of byte conversion.
func (BytesIEC) HumanReadable ¶ added in v0.3.0
HumanReadable returns the biggest sensible unit for the byte value with 2 decimal precision.
When value is smaller than 2 render it with a lower scale.
type BytesSI ¶ added in v0.3.0
type BytesSI uint64
BytesSI is the SI (1000) unit implementation of byte conversion.
func (BytesSI) HumanReadable ¶ added in v0.3.0
HumanReadable returns the biggest sensible unit for the byte value with 2 decimal precision.
When value is smaller than 2 render it with a lower scale.