Documentation
¶
Index ¶
- Constants
- func Format(value int64) string
- func FormatBinary(value int64) string
- func FormatDecimal(value int64) string
- func Parse(value string) (int64, error)
- type Bytes
- func (b *Bytes) Format(value int64) string
- func (*Bytes) FormatBinary(value int64) string
- func (*Bytes) FormatDecimal(value int64) string
- func (b *Bytes) Parse(value string) (int64, error)
- func (*Bytes) ParseBinary(value string) (i int64, err error)
- func (*Bytes) ParseDecimal(value string) (i int64, err error)
Constants ¶
const ( KiB MiB GiB TiB PiB EiB )
binary units (IEC 60027)
const ( KB = 1000 MB = KB * 1000 GB = MB * 1000 TB = GB * 1000 PB = TB * 1000 EB = PB * 1000 )
decimal units (SI international system of units)
Variables ¶
This section is empty.
Functions ¶
func FormatBinary ¶ added in v0.4.0
FormatBinary wraps global Bytes's FormatBinary function.
func FormatDecimal ¶ added in v0.4.0
FormatDecimal wraps global Bytes's FormatDecimal function.
Types ¶
type Bytes ¶
type Bytes struct{}
Bytes struct
func (*Bytes) Format ¶
Format formats bytes integer to human readable string according to IEC 60027. For example, 31323 bytes will return 30.59KB.
func (*Bytes) FormatBinary ¶ added in v0.4.0
FormatBinary formats bytes integer to human readable string according to IEC 60027. For example, 31323 bytes will return 30.59KB.
func (*Bytes) FormatDecimal ¶ added in v0.4.0
FormatDecimal formats bytes integer to human readable string according to SI international system of units. For example, 31323 bytes will return 31.32KB.
func (*Bytes) Parse ¶
Parse parses human readable bytes string to bytes integer. For example, 6GiB (6Gi is also valid) will return 6442450944, and 6GB (6G is also valid) will return 6000000000.
func (*Bytes) ParseBinary ¶ added in v0.4.0
ParseBinary parses human readable bytes string to bytes integer. For example, 6GiB (6Gi is also valid) will return 6442450944.