util

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BIT  = "b"
	BYTE = "B"

	KILO   = "K"
	MEGA   = "M"
	GIGA   = "G"
	TERA   = "T"
	PETA   = "P"
	EXA    = "E"
	ZETTA  = "Z"
	YOTTA  = "Y"
	RONNA  = "R"
	QUETTA = "Q"

	KIBI  = "Ki"
	MEBI  = "Mi"
	GIBI  = "Gi"
	TEBI  = "Ti"
	EXBI  = "Ei"
	PEBI  = "Pi"
	ZEBI  = "Zi"
	YOBI  = "Yi"
	ROBI  = "Ri"
	QUEBI = "Qi"
)
View Source
const BINARY_KILO = 1024
View Source
const DECIMAL_KILO = 1000

Variables

This section is empty.

Functions

func Average added in v0.3.8

func Average(xs []float64) float64

func BytesToBits

func BytesToBits(b float64) float64

func BytesToGibiBytes

func BytesToGibiBytes(b float64) float64

func BytesToMebiBytes

func BytesToMebiBytes(b float64) float64

func BytesToMegaBytes

func BytesToMegaBytes(b float64) float64

func CommonBase added in v0.3.8

func CommonBase(strings ...string) string

func KibiBytesToMebiBytes added in v0.2.2

func KibiBytesToMebiBytes(b float64) float64

func ParseZfsSize added in v0.3.0

func ParseZfsSize(size string) (float64, error)

func RoundNDecimals added in v0.4.0

func RoundNDecimals[T Float](n int) func(T) T

func RoundTwoDecimals

func RoundTwoDecimals[T Float](n T) T

func SizeConvertionFunction added in v0.4.0

func SizeConvertionFunction(fromUnitLabel string, toUnitLabel string) func(float64) float64

Types

type Float added in v0.4.0

type Float interface {
	~float64
}

type IndexedValue added in v0.2.2

type IndexedValue[T any] struct {
	Index int
	Value T
}

type MapWithDefault added in v0.4.0

type MapWithDefault[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewMapWithDefault added in v0.4.0

func NewMapWithDefault[K comparable, V any](internalMap map[K]V, defaultValue V) MapWithDefault[K, V]

func (MapWithDefault[K, V]) Get added in v0.4.0

func (mwd MapWithDefault[K, V]) Get(key K) V

type UnitPrefix added in v0.4.0

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

func NewUnitPrefix added in v0.4.0

func NewUnitPrefix(label string, exponent int) UnitPrefix

Jump to

Keyboard shortcuts

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