Documentation ¶
Overview ¶
Package bytesize provides functionality for measuring and formatting byte sizes.
You can also perform mathematical operation with ByteSize's and the result will be a valid ByteSize with the correct size suffix.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // LongUnits Use long units, such as "megabytes" instead of "MB". LongUnits = false // Format String format of bytesize output. The unit of measure will be appended // to the end. Uses the same formatting options as the fmt package. Format = "%.2f" )
Functions ¶
This section is empty.
Types ¶
type ByteSize ¶
type ByteSize uint64
ByteSize represents a number of bytes
func Parse ¶
Parse parses a byte size string. A byte size string is a number followed by a unit suffix, such as "1024B" or "1 MB". Valid byte units are "B", "KB", "MB", "GB", "TB", "PB" and "EB". You can also use the long format of units, such as "kilobyte" or "kilobytes".
func (ByteSize) Format ¶
Format Returns a string representation of b with the specified formatting and units.
func (*ByteSize) Get ¶
func (b *ByteSize) Get() interface{}
Get Satisfy the flag package Getter interface.
func (ByteSize) String ¶
String returns the string form of b using the package global Format and LongUnits options.
func (*ByteSize) UnmarshalText ¶
UnmarshalText Satisfy the encoding.TextUnmarshaler interface.