datasize

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: BSD-3-Clause Imports: 4 Imported by: 2

Documentation

Overview

Package datasize provides a data size type and constants.

Index

Constants

View Source
const (
	B  Size = 1
	KB      = B << 10
	MB      = KB << 10
	GB      = MB << 10
	TB      = GB << 10
	PB      = TB << 10
	EB      = PB << 10
)

Variables

View Source
var ErrBits = errors.New("unit with capital unit prefix and lower case unit (b) - bits, not bytes")

Functions

This section is empty.

Types

type Size

type Size uint64

Size represents a data size.

func MustParse

func MustParse(t []byte) Size

func MustParseString

func MustParseString(s string) Size

func Parse

func Parse(t []byte) (Size, error)

func ParseString

func ParseString(s string) (Size, error)

func (Size) Bytes

func (b Size) Bytes() uint64

func (Size) EBytes

func (b Size) EBytes() float64

func (Size) GBytes

func (b Size) GBytes() float64

func (Size) KBytes

func (b Size) KBytes() float64

func (Size) MBytes

func (b Size) MBytes() float64

func (Size) MachineString

func (b Size) MachineString() string

MachineString returns a machine-friendly representation of the data size.

func (Size) MarshalText

func (b Size) MarshalText() ([]byte, error)

func (Size) PBytes

func (b Size) PBytes() float64

func (Size) String

func (b Size) String() string

String returns a human-readable representation of the data size.

func (Size) TBytes

func (b Size) TBytes() float64

func (*Size) UnmarshalText

func (b *Size) UnmarshalText(t []byte) error

Jump to

Keyboard shortcuts

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