unitx

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package unitx provides a set of utilities for working with unit types in Go.

Index

Constants

View Source
const (
	// Decimal.
	KB = 1000
	MB = 1000 * KB
	GB = 1000 * MB
	TB = 1000 * GB
	PB = 1000 * TB

	// Binary.
	KiB = 1024
	MiB = 1024 * KiB
	GiB = 1024 * MiB
	TiB = 1024 * GiB
	PiB = 1024 * TiB
)

See: http://en.wikipedia.org/wiki/Binary_prefix

Variables

This section is empty.

Functions

This section is empty.

Types

type HumanSize

type HumanSize string

HumanByteSize represents a human-readable byte size.

func (HumanSize) ToInt

func (h HumanSize) ToInt() (int, error)

ToInt converts the human size to an integer.

func (HumanSize) ToInt32

func (h HumanSize) ToInt32() (int32, error)

ToInt32 converts the human size to an 32 bit integer.

func (HumanSize) ToInt64

func (h HumanSize) ToInt64() (int64, error)

ToInt64 converts the human size to an 64 bit integer. nolint: gocyclo

type Integerer

type Integerer interface {
	// ToInt converts the integer to an integer.
	ToInt() (int, error)
	// ToInt64 converts the integer to an 64 bit integer.
	ToInt64() (int64, error)
	// ToInt32 converts the integer to an 32 bit integer.
	ToInt32() (int32, error)
}

Integerer represents an integer.

Jump to

Keyboard shortcuts

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