quantity

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OffsetKiB is the byte size of one kibibyte (2^10 = 1024 bytes)
	OffsetKiB = Offset(1 << 10)
	// OffsetMiB is the offset of one mebibyte (2^20)
	OffsetMiB = Offset(1 << 20)
)
View Source
const (
	// SizeKiB is the byte size of one kibibyte (2^10 = 1024 bytes)
	SizeKiB = Size(1 << 10)
	// SizeMiB is the size of one mebibyte (2^20)
	SizeMiB = Size(1 << 20)
	// SizeGiB is the size of one gibibyte (2^30)
	SizeGiB = Size(1 << 30)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Offset

type Offset Size

Offset describes the offset in bytes and is a thin wrapper around Size.

func ParseOffset

func ParseOffset(gs string) (Offset, error)

ParseOffset parses a string expressing offset in a gadget specific format. The accepted format is one of: <bytes> | <bytes/2^20>M | <bytes/2^30>G.

func (*Offset) IECString

func (o *Offset) IECString() string

IECString formats the offset using multiples from IEC units (i.e. kibibytes, mebibytes), that is as multiples of 1024. Printed values are truncated to 2 decimal points.

func (*Offset) String

func (o *Offset) String() string

func (*Offset) UnmarshalYAML

func (o *Offset) UnmarshalYAML(unmarshal func(interface{}) error) error

type Size

type Size uint64

Size describes the size in bytes.

func ParseSize

func ParseSize(gs string) (Size, error)

ParseSize parses a string expressing size in a gadget specific format. The accepted format is one of: <bytes> | <bytes/2^20>M | <bytes/2^30>G.

func (Size) IECString

func (s Size) IECString() string

IECString formats the size using multiples from IEC units (i.e. kibibytes, mebibytes), that is as multiples of 1024. Printed values are truncated to 2 decimal points.

func (*Size) String

func (s *Size) String() string

func (*Size) UnmarshalYAML

func (s *Size) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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