humanize

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IEC Sizes in kibis of bits
	Byte = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
	TiByte
	PiByte
	EiByte

	// SI Sizes.
	IByte = 1
	KByte = IByte * 1000
	MByte = KByte * 1000
	GByte = MByte * 1000
	TByte = GByte * 1000
	PByte = TByte * 1000
	EByte = PByte * 1000
	ZByte = EByte * 1000
)

Variables

This section is empty.

Functions

func Bytes

func Bytes(s uint64) string

Bytes converts a byte count into a human-readable string using decimal (SI) units (kB, MB, GB, etc.). It uses a base of 1000 (1 kB = 1000 bytes).

func IBytes

func IBytes(s uint64) string

IBytes converts a byte count into a human-readable string using binary (IEC) units (KiB, MiB, GiB, etc.). It uses a base of 1024 (1 KiB = 1024 bytes).

func ParseBytes

func ParseBytes(s string) (uint64, error)

ParseBytes parses a string representation of bytes (like "1.5 GB" or "1024 B") and returns the number of bytes it represents. It supports both decimal (SI) and binary (IEC) units and handles values with commas as well.

Types

This section is empty.

Jump to

Keyboard shortcuts

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