Documentation ¶
Overview ¶
Package bytefmt contains helper methods and constants for converting to and from a human-readable byte format.
bytefmt.ByteSize(100.5*bytefmt.Megabyte) // "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 form 10M, 12.5K, and so forth. The following units are available:
T: Terabyte G: Gigabyte M: Megabyte K: Kilobyte B: Byte
The unit that results in the smallest number greater than or equal to 1 is always chosen.
func ToMegabytes ¶
ToMegabytes parses a string formatted by ByteSize as megabytes.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.