storageunit

package module
v0.0.0-...-123b67f Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 4 Imported by: 1

README

storageunit

Intro

storage units like time.Duration

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringToBitsHookFunc

func StringToBitsHookFunc() mapstructure.DecodeHookFunc

func StringToBytesHookFunc

func StringToBytesHookFunc() mapstructure.DecodeHookFunc

Types

type Bits

type Bits uint64
const (
	Bit     Bits = 1
	Kilobit Bits = 1000
	Megabit Bits = 1000 * Kilobit
	Gigabit Bits = 1000 * Megabit
	Terabit Bits = 1000 * Gigabit
	Petabit Bits = 1000 * Terabit
	Exabit  Bits = 1000 * Petabit

	MaxBitUnit Bits = 1<<64 - 1
	MinBitUnit Bits = 0
)

func ParseBits

func ParseBits(s string) (Bits, error)

func (Bits) Byte

func (b Bits) Byte() Bytes

func (Bits) Exabits

func (b Bits) Exabits() float64

func (Bits) Gigabits

func (b Bits) Gigabits() float64

func (Bits) Kilobits

func (b Bits) Kilobits() float64

func (Bits) MarshalJSON

func (b Bits) MarshalJSON() ([]byte, error)

func (Bits) MarshalText

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

func (Bits) Megabits

func (b Bits) Megabits() float64

func (Bits) Petabits

func (b Bits) Petabits() float64

func (Bits) String

func (b Bits) String() string

func (Bits) Terabits

func (b Bits) Terabits() float64

func (*Bits) UnmarshalJSON

func (b *Bits) UnmarshalJSON(bs []byte) error

func (*Bits) UnmarshalText

func (b *Bits) UnmarshalText(bs []byte) error

type Bytes

type Bytes uint64
const (
	Byte     Bytes = 8
	Kilobyte Bytes = 1024 * Byte
	Megabyte Bytes = 1024 * Kilobyte
	Gigabyte Bytes = 1024 * Megabyte
	Terabyte Bytes = 1024 * Gigabyte
	Petabyte Bytes = 1024 * Terabyte
	Exabyte  Bytes = 1024 * Petabyte

	MaxByteUnit Bytes = 1<<64 - 1
	MinByteUnit Bytes = 0
)

func ParseBytes

func ParseBytes(s string) (Bytes, error)

func (Bytes) Bit

func (b Bytes) Bit() Bits

func (Bytes) Exabytes

func (b Bytes) Exabytes() float64

func (Bytes) Gigabytes

func (b Bytes) Gigabytes() float64

func (Bytes) Kilobytes

func (b Bytes) Kilobytes() float64

func (Bytes) MarshalJSON

func (b Bytes) MarshalJSON() ([]byte, error)

func (Bytes) MarshalText

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

func (Bytes) Megabytes

func (b Bytes) Megabytes() float64

func (Bytes) Petabytes

func (b Bytes) Petabytes() float64

func (Bytes) String

func (b Bytes) String() string

func (Bytes) Terabytes

func (b Bytes) Terabytes() float64

func (*Bytes) UnmarshalJSON

func (b *Bytes) UnmarshalJSON(bs []byte) error

func (*Bytes) UnmarshalText

func (b *Bytes) UnmarshalText(bs []byte) error

Jump to

Keyboard shortcuts

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