Documentation ¶
Overview ¶
bytefmt contains helper methods and constants for converting to and from a human readable byte format.
bytefmt.ByteSize(100.5*bytefmt.MEGABYE) // "100.5M" bytefmt.ByteSize(uint64(1024)) // "1K"
Index ¶
Constants ¶
View Source
const ( BYTE = 1.0 KILOBYTE = 1024 * BYTE MEGABYTE = 1024 * KILOBYTE GIGABYTE = 1024 * MEGABYTE TERABYTE = 1024 * GIGABYTE )
Variables ¶
This section is empty.
Functions ¶
func ByteSize ¶
ByteSize returns a human readable byte string, of the format 10M, 12.5K, etc. The following units are available:
T Terabyte G Gigabyte M Megabyte K Kilobyte
the unit that would result in printing the smallest whole number is always chosen
func ToMegabytes ¶
ToMegabyte parses a string formatted by ByteSize as megabytes
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.