sizeconv

package
v3.0.0-rc21 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KB is KiloByte
	KB = 1000
	// MB is MegaByte
	MB = 1000 * KB
	// GB is GigaByte
	GB = 1000 * MB
	// TB is TeraByte
	TB = 1000 * GB
	// PB is PetaByte
	PB = 1000 * TB
	// EB is ExaByte
	EB = 1000 * PB

	// KiB is KibiByte
	KiB = 1024
	// MiB is MibiByte
	MiB = 1024 * KiB
	// GiB is GibiByte
	GiB = 1024 * MiB
	// TiB is TibiByte
	TiB = 1024 * GiB
	// PiB is Pebibyte
	PiB = 1024 * TiB
	// EiB is Exbibyte
	EiB = 1024 * PiB
)

Variables

This section is empty.

Functions

func BSize

func BSize(size float64) string

BSize returns a human-readable, default precision, representation of size in binary units.

func BSizeCompact

func BSizeCompact(f float64) string

BSizeCompact returns a compact human readable version of n

func BSizeWithPrecision

func BSizeWithPrecision(size float64, precision int) string

BSizeWithPrecision returns a human-readable, arbitrary precision, representation of size in binary units.

func CustomExactSize

func CustomExactSize(format string, precision int, size float64, base float64, _map []string, compact bool) string

func CustomSize

func CustomSize(format string, precision int, size float64, base float64, _map []string, compact bool) string

CustomSize returns a human-readable approximation of a size using custom format and precision.

func DSize

func DSize(size float64) string

DSize returns a human-readable, default precision, representation of size in SI units.

func DSizeCompact

func DSizeCompact(f float64) string

func DSizeWithPrecision

func DSizeWithPrecision(size float64, precision int) string

DSizeWithPrecision returns a human-readable, arbitrary precision, representation of size in SI units.

func ExactBSizeCompact

func ExactBSizeCompact(f float64) string

func ExactDSizeCompact

func ExactDSizeCompact(f float64) string

func FromDSize

func FromDSize(size string) (int64, error)

FromDSize returns an integer from a human-readable representation of a size using SI standard (eg. "44kB", "17MB").

func FromSize

func FromSize(sizeStr string) (int64, error)

FromSize returns an integer from a human-readable representation of a size using Metric and IEC standard (eg. "44KiB", "17MiB", "20MB", "7.5EiB"). Max possible value is MaxInt64 (< 8EiB)

func PrintSigFixed

func PrintSigFixed(value float64, N int, compact bool) string

PrintSigFixed formats a float to N significant digits using fixed-point notation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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