Documentation ¶
Index ¶
Constants ¶
View Source
const ( // BYTE represents one byte. BYTE = 1.0 // KILOBYTE represents kilo bytes. KILOBYTE = 1024 // MEGABYTE represents mega bytes. MEGABYTE = 1024 * KILOBYTE //GIGABYTE represents giga bytes. GIGABYTE = 1024 * MEGABYTE // TERABYTE represents tera bytes. TERABYTE = 1024 * GIGABYTE )
Variables ¶
View Source
var ErrorInvalidByte = errors.New("Byte quantity must be a positive integer with a unit of measurement like M, MB, G, or GB")
ErrorInvalidByte is the error that presents the format of string is not a valid byte.
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 ToKilobytes ¶
ToKilobytes parses a string formatted by ByteSize as kilobytes.
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.