Documentation ¶
Overview ¶
Package units provides a set of functions to convert between bytes and human-readable formats.
Index ¶
- Constants
- func BytesSize(size float64) string
- func CustomSize(format string, size float64, base float64, _map []string) string
- func FromHumanSize(size string) (int64, error)
- func HumanDuration(d time.Duration) string
- func HumanSize(size float64) string
- func HumanSizeWithPrecision(size float64, precision int) string
- func RAMInBytes(size string) (int64, error)
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func BytesSize ¶ added in v0.4.8
BytesSize returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").
func CustomSize ¶ added in v0.4.8
CustomSize returns a human-readable approximation of a size using custom format.
func FromHumanSize ¶ added in v0.4.8
FromHumanSize returns an integer from a human-readable specification of a size using SI standard (eg. "44kB", "17MB").
func HumanDuration ¶
HumanDuration returns a human-readable approximation of a duration (e.g. "About a minute", "4 hours ago", etc.).
func HumanSize ¶ added in v0.4.8
HumanSize returns a human-readable approximation of a size capped at 4 valid numbers (eg. "2.746 MB", "796 KB").
func HumanSizeWithPrecision ¶ added in v0.4.8
HumanSizeWithPrecision allows the size to be in any precision, instead of 4 digit precision used in units.HumanSize.
func RAMInBytes ¶ added in v0.4.8
RAMInBytes parses a human-readable string representing an amount of RAM in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and returns the number of bytes, or -1 if the string is unparseable. Units are case-insensitive, and the 'b' suffix is optional.
Types ¶
This section is empty.