Documentation ¶
Overview ¶
Package datasize implements a type representing data sizes in bytes.
Index ¶
- Constants
- type Size
- func (s Size) Bytes() uint64
- func (s Size) Floor() Size
- func (s Size) Gibibytes() float64
- func (s Size) Gigabytes() float64
- func (s Size) Kibibytes() float64
- func (s Size) Kilobytes() float64
- func (s Size) Mebibytes() float64
- func (s Size) Megabytes() float64
- func (s Size) Pebibytes() float64
- func (s Size) Petabytes() float64
- func (s Size) Round() Size
- func (s Size) String() string
- func (s Size) Tebibytes() float64
- func (s Size) Terabytes() float64
Constants ¶
View Source
const ( Kilobyte Size = 1000 * Byte Megabyte = 1000 * Kilobyte Gigabyte = 1000 * Megabyte Terabyte = 1000 * Gigabyte Petabyte = 1000 * Terabyte )
Common decimal data sizes
View Source
const ( Byte Size = 1 Kibibyte = 1024 * Byte Mebibyte = 1024 * Kibibyte Gibibyte = 1024 * Mebibyte Tebibyte = 1024 * Gibibyte Pebibyte = 1024 * Tebibyte )
Common binary data sizes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Size ¶
type Size uint64
Size represents the size of data in bytes.
func FlagVar ¶ added in v0.0.64
FlagVar defines a Size flag with specified name, default value, and usage string into the provided FlagSet.
func Parse ¶
Parse parses a Size from a string. A Size is an unsigned decimal number with an optional fraction and a unit suffix. Examples: "0", "10B", "1kB", "4GB", "5GiB". Valid units are "B", (decimal: "kB", "MB", "GB, "TB, "PB"), (binary: "KiB", "MiB", "GiB", "TiB", "PiB")
func (Size) Floor ¶ added in v0.0.59
Floor returns a Size nearest to a whole unit less than or equal to itself.
Click to show internal directories.
Click to hide internal directories.