bytefmt

package
v0.0.0-...-43b4bc3 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ByteUnit     = "b"
	KilobyteUnit = "kb"
	MegabyteUnit = "mb"
	GigabyteUnit = "gb"
	TerabyteUnit = "tb"
	PetabyteUnit = "pb"
	ExabyteUnit  = "eb"
)
View Source
const (
	Byte     = 1
	Kilobyte = 1024
	Megabyte = 1024 * 1024
	Gigabyte = 1024 * 1024 * 1024
	Terabyte = 1024 * 1024 * 1024 * 1024
	Petabyte = 1024 * 1024 * 1024 * 1024 * 1024
	Exabyte  = 1024 * 1024 * 1024 * 1024 * 1024 * 1024
)

Variables

This section is empty.

Functions

func ToString

func ToString(bytes ByteSize) string

ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth. The following units are available: The unit that results in the smallest number greater than or equal to 1 is always chosen.

Types

type ByteSize

type ByteSize int64

func FromString

func FromString(s string) (ByteSize, error)

ToBytes parses a string formatted by ByteSize as bytes. Note, this is based on the basis of 2 (no KiB, ...).

func (ByteSize) MarshalYAML

func (t ByteSize) MarshalYAML() (interface{}, error)

func (*ByteSize) UnmarshalYAML

func (f *ByteSize) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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