Documentation
¶
Index ¶
- Variables
- type Size
- func (s Size) Bytes() float64
- func (s Size) BytesString() string
- func (s Size) Exabytes() float64
- func (s Size) Exbibytes() float64
- func (s Size) Format(unit Size, precision ...int) string
- func (s Size) Gibibytes() float64
- func (s Size) Gigabytes() float64
- func (s Size) HumanReadable() string
- 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) String() string
- func (s Size) Tebibytes() float64
- func (s Size) Terabytes() float64
Constants ¶
This section is empty.
Variables ¶
Buffer32k pool to reduce memory pressure when handling large amount of file operations (32KB buffers)
Functions ¶
This section is empty.
Types ¶
type Size ¶
type Size int64
Size represents a byte size. The representation limits the largest representable size to approximately 8 exabytes.
func ParseSize ¶
ParseSize parses a size string. A size string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300KB", "1.5GiB" or "2.5MB". Valid size units are "B", "KB", "KiB", "MB", "MiB", "GB", "GiB", "TB", "TiB", "PB", "PiB", "EB", "EiB".
func (Size) BytesString ¶
BytesString returns the size as a string with "B" suffix.
func (Size) Format ¶
Format returns the size formatted with the specified unit. The unit should be one of: B, KB, KiB, MB, MiB, GB, GiB, TB, TiB, PB, PiB, EB, EiB. Precision is optional - if not provided or negative, it defaults to defaultPrecision.
func (Size) HumanReadable ¶
HumanReadable returns a human-readable string using the highest appropriate unit with fractions. It automatically selects the best unit that keeps the value >= 1.
func (Size) String ¶
String returns a string representation of the size. It uses the largest unit that evenly divides the size.