datasizes

package
v0.104.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	KiloByte = 1000                      // kB
	KibiByte = 1024                      // KiB
	MegaByte = 1000 * 1000               // MB
	MebiByte = 1024 * 1024               // MiB
	GigaByte = 1000 * 1000 * 1000        // GB
	GibiByte = 1024 * 1024 * 1024        // GiB
	TeraByte = 1000 * 1000 * 1000 * 1000 // TB
	TebiByte = 1024 * 1024 * 1024 * 1024 // TiB

	// shorthands
	KiB = KibiByte
	MB  = MegaByte
	MiB = MebiByte
	GB  = GigaByte
	GiB = GibiByte
	TiB = TebiByte
)

Variables

This section is empty.

Functions

func Parse

func Parse(size string) (uint64, error)

Parse converts a size specified as a string in KB/KiB/MB/etc. to a number of bytes represented by uint64.

Types

type Size added in v0.101.0

type Size uint64

Size is a wrapper around uint64 with support for reading from string yaml/toml, so {"size": 123}, {"size": "1234"}, {"size": "1 GiB"} are all supported

func (Size) Uint64 added in v0.101.0

func (si Size) Uint64() uint64

Uint64 returns the size as uint64. This is a convenience functions, it is strictly equivalent to uint64(Size(1))

func (*Size) UnmarshalJSON added in v0.101.0

func (si *Size) UnmarshalJSON(data []byte) error

func (*Size) UnmarshalTOML added in v0.101.0

func (si *Size) UnmarshalTOML(data interface{}) error

Jump to

Keyboard shortcuts

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