datasize

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Invalid Unit = iota
	Byte
	Kilobyte
	Megabyte
	Gigabyte
	Terabyte
	Petabyte
	Exabyte

	Kibibyte = iota + gap - Exabyte + 1
	Mebibyte
	Gibibyte
	Tebibyte
	Pebibyte
	Exbibyte
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSize

type DataSize struct {
	// contains filtered or unexported fields
}

func New

func New(magnitude *big.Float, unit Unit) DataSize

func Parse added in v0.5.0

func Parse(input string) (DataSize, error)

Parse always parses using big and `RoundingMode.ToNearestAway`.

func (DataSize) Add added in v0.6.0

func (d DataSize) Add(o DataSize) DataSize

Add sums two numbers together, converting to the highest unit with a magnitude above 1. The result will be in the unit system (SI or std) of d.

func (DataSize) Gte added in v0.6.1

func (d DataSize) Gte(o DataSize) bool

func (DataSize) String

func (d DataSize) String() string

func (DataSize) Sub added in v0.6.1

func (d DataSize) Sub(o DataSize) DataSize

func (DataSize) ToBytes added in v0.6.0

func (d DataSize) ToBytes() DataSize

func (DataSize) ToHumanReadable

func (d DataSize) ToHumanReadable() DataSize

func (DataSize) ToHumanReadableSi added in v0.6.0

func (d DataSize) ToHumanReadableSi() DataSize

type Unit

type Unit int

func UnitFromString added in v0.5.0

func UnitFromString(input string, assumeSi bool) (Unit, error)

func (Unit) Base

func (u Unit) Base() int

func (Unit) IsSi

func (u Unit) IsSi() bool

IsSi reports if the Unit is an SI unit (Système international).

func (Unit) Next

func (u Unit) Next() (Unit, bool)

func (Unit) Previous

func (u Unit) Previous() (Unit, bool)

func (Unit) ShortString

func (u Unit) ShortString() string

func (Unit) String

func (u Unit) String() string

func (Unit) ToSi added in v0.6.0

func (u Unit) ToSi() Unit

ToSi converts

func (Unit) ToStd added in v0.6.0

func (u Unit) ToStd() Unit

Jump to

Keyboard shortcuts

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