Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Size ¶
type Size int64
Size is an integer alias that allows for custom string formatting options * SI Decimal units: kB(1000), MB(1000^2), GB(1000^3), TB(1000^4), PB(1000^5), EB(1000^6) * Binary ISO/IEC units: KiB kibibyte(1024), MiB mebibyte(1024^2) GiB gibibyte(1024^3) TiB tebibyte(1024^4) PiB pebibyte(1024^5) EiB exbibyte(1024^6) * Binary JDEC units[3]: KB, MB, GB, TB Past "Exa" we're outside what int64 can represent, so we stop there.
[1] https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
func (Size) Format ¶
Format outputs the three types of representation.
Example ¶
const notSoManyBytes = Size(4096) const manyBytes = Size(math.MaxInt64) fmt.Printf("not so many bytes: %.2I %.2B %.2J\n", notSoManyBytes, notSoManyBytes, notSoManyBytes) fmt.Printf("so many bytes: %.3I %.3B %.3J", manyBytes, manyBytes, manyBytes)
Output: not so many bytes: 4.10kB 4.00KiB 4.00KB so many bytes: 9.223EB 8.000EiB 8.000EB
Click to show internal directories.
Click to hide internal directories.