Documentation
¶
Index ¶
- Constants
- func BigComma(bin *big.Int) string
- func Bytes(s uint64) string
- func BytesN(s uint64, n int) string
- func Comma(v int64) string
- func Commaf(v float64) string
- func CommafWithDigits(f float64, decimals int) string
- func Ftoa(num float64) string
- func FtoaWithDigits(num float64, digits int) string
- func IBytes(s uint64) string
- func IBytesN(s uint64, n int) string
- func ParseBytes(s string) (uint64, error)
- func ShortLogger(l string) string
Constants ¶
const ( Byte = 1 << (iota * 10) KiByte MiByte GiByte TiByte PiByte EiByte )
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.
Variables ¶
This section is empty.
Functions ¶
func BigComma ¶
BigComma produces a string form of the given big.Int in base 10 with commas after every three orders of magnitude.
func Bytes ¶
Bytes produces a human-readable representation of an SI size.
See also: ParseBytes.
Bytes(82854982) -> 83 MB
func BytesN ¶
BytesN produces a human-readable representation of an SI size. n specifies the total number of digits to output, including the decimal part. If n is less than or equal to the number of digits in the integer part, the decimal part will be omitted.
See also: ParseBytes.
BytesN(82854982, 3) -> 82.9 MB BytesN(82854982, 4) -> 82.85 MB
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 Commaf ¶
Commaf produces a string form of the given number in base 10 with commas after every three orders of magnitude.
e.g. Commaf(834142.32) -> 834,142.32
func CommafWithDigits ¶
CommafWithDigits works like the Commaf but limits the resulting string to the given number of decimal places.
e.g. CommafWithDigits(834142.32, 1) -> 834,142.3
func FtoaWithDigits ¶
FtoaWithDigits converts a float to a string but limits the resulting string to the given number of decimal places, and no trailing zeros.
func IBytes ¶
IBytes produces a human-readable representation of an IEC size.
See also: ParseBytes.
IBytes(82854982) -> 79 MiB
func IBytesN ¶
IBytesN produces a human-readable representation of an IEC size. n specifies the total number of digits to output, including the decimal part. If n is less than or equal to the number of digits in the integer part, the decimal part will be omitted.
See also: ParseBytes.
IBytesN(82854982, 4) -> 79.02 MiB IBytesN(123456789, 3) -> 118 MiB IBytesN(123456789, 6) -> 117.738 MiB
func ParseBytes ¶
ParseBytes parses a string representation of bytes into the number of bytes it represents.
See Also: Bytes, IBytes.
ParseBytes("42 MB") -> 42000000, nil ParseBytes("42 mib") -> 44040192, nil
Types ¶
This section is empty.
Source Files
¶
- bytes.go
- comma.go
- ftoa.go
- oomm.go
- path.go