Documentation ¶
Overview ¶
Package humanize converts boring ugly numbers to human-friendly strings.
Durations can be turned into strings such as "3 days ago", numbers representing sizes like 82854982 into useful strings like, "83MB" or "79MiB" (whichever you prefer).
Index ¶
Constants ¶
const ( Byte = 1 KiByte = Byte * 1024 MiByte = KiByte * 1024 GiByte = MiByte * 1024 TiByte = GiByte * 1024 PiByte = TiByte * 1024 EiByte = PiByte * 1024 )
IEC Sizes. kibis of bits
const ( IByte = 1 KByte = IByte * 1000 MByte = KByte * 1000 GByte = MByte * 1000 TByte = GByte * 1000 PByte = TByte * 1000 EByte = PByte * 1000 )
SI Sizes.
const ( Minute = 60 Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day Month = 30 * Day Year = 12 * Month )
Seconds-based time units
Variables ¶
This section is empty.
Functions ¶
func Comma ¶
Comma produces a string form of the given number in base 10 with commas after every three orders of magnitude. e.g. Comma(834142) -> 834,142
func IBytes ¶
IBytes produces a human readable representation of an IEC size. IBytes(82854982) -> 79MiB
func ParseBytes ¶
ParseBytes parses a string representation of bytes into the number of bytes it represents. ParseBytes("42MB") -> 42000000, nil ParseBytes("42mib") -> 44040192, nil
Types ¶
This section is empty.