bytesize

package
v3.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bytesize parses and formats byte counts written as size strings such as "32MiB".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(n int64) string

Format renders n with the largest binary unit that divides it exactly, so a value Parse accepted reads back the way it was written ("32MiB"). Other values print as bytes.

func Parse

func Parse(s string) (int64, error)

Parse reads a size such as "8MiB", "32 MiB", "512KiB", "1GiB" or a bare integer number of bytes. Units are the binary ones (KiB, MiB, GiB) and are case-insensitive; "B" is accepted for plain bytes. Decimal units (KB, MB) are refused rather than guessed, since they are routinely read both ways. The result must be positive and fit in an int64.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL