data

package
v0.0.0-...-187dae4 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 2 Imported by: 0

README

data

import "github.com/mjpitz/units/data"

Usage

const (
	Byte Size = 1

	Kibibyte = Byte << 10
	Mebibyte = Kibibyte << 10
	Gibibyte = Mebibyte << 10
	Tebibyte = Gibibyte << 10
	Pebibyte = Tebibyte << 10

	Kilobyte = Byte * 1000
	Megabyte = Kilobyte * 1000
	Gigabyte = Megabyte * 1000
	Terabyte = Gigabyte * 1000
	Petabyte = Terabyte * 1000
)
var (
	Decimal = units.Unit[Size]{
		{Byte, []string{"B"}},
		{Kilobyte, []string{"kB"}},
		{Megabyte, []string{"MB"}},
		{Gigabyte, []string{"GB"}},
		{Terabyte, []string{"TB"}},
		{Petabyte, []string{"PB"}},
	}

	BinaryIEC = units.Unit[Size]{
		{Byte, []string{"B"}},
		{Kibibyte, []string{"KiB"}},
		{Mebibyte, []string{"MiB"}},
		{Gibibyte, []string{"GiB"}},
		{Tebibyte, []string{"TiB"}},
		{Pebibyte, []string{"PiB"}},
	}

	BinaryMemory = units.Unit[Size]{
		{Byte, []string{"B"}},
		{Kibibyte, []string{"KB"}},
		{Mebibyte, []string{"MB"}},
		{Gibibyte, []string{"GB"}},
		{Tebibyte, []string{"TB"}},
	}
)
type Size
type Size int64

Size defines how we measure digital information (typically in the number of bytes). Digital information refers to any data or content that is represented, stored, or transmitted in a digital format. It is composed of discrete units known as bits, which can be either 0 or 1. Digital information can take various forms, such as text, images, audio, video, or any other type of data that can be encoded and processed electronically.

func (Size) As
func (u Size) As(other Size) float64
func (*Size) Set
func (u *Size) Set(val string) error
func (Size) String
func (u Size) String() string

Documentation

Index

Constants

View Source
const (
	Byte Size = 1

	Kibibyte = Byte << 10
	Mebibyte = Kibibyte << 10
	Gibibyte = Mebibyte << 10
	Tebibyte = Gibibyte << 10
	Pebibyte = Tebibyte << 10

	Kilobyte = Byte * 1000
	Megabyte = Kilobyte * 1000
	Gigabyte = Megabyte * 1000
	Terabyte = Gigabyte * 1000
	Petabyte = Terabyte * 1000
)

Variables

View Source
var (
	Decimal = units.Unit[Size]{
		{Byte, []string{"B"}},
		{Kilobyte, []string{"kB"}},
		{Megabyte, []string{"MB"}},
		{Gigabyte, []string{"GB"}},
		{Terabyte, []string{"TB"}},
		{Petabyte, []string{"PB"}},
	}

	BinaryIEC = units.Unit[Size]{
		{Byte, []string{"B"}},
		{Kibibyte, []string{"KiB"}},
		{Mebibyte, []string{"MiB"}},
		{Gibibyte, []string{"GiB"}},
		{Tebibyte, []string{"TiB"}},
		{Pebibyte, []string{"PiB"}},
	}

	BinaryMemory = units.Unit[Size]{
		{Byte, []string{"B"}},
		{Kibibyte, []string{"KB"}},
		{Mebibyte, []string{"MB"}},
		{Gibibyte, []string{"GB"}},
		{Tebibyte, []string{"TB"}},
	}
)

Functions

This section is empty.

Types

type Size

type Size int64

Size defines how we measure digital information (typically in the number of bytes). Digital information refers to any data or content that is represented, stored, or transmitted in a digital format. It is composed of discrete units known as bits, which can be either 0 or 1. Digital information can take various forms, such as text, images, audio, video, or any other type of data that can be encoded and processed electronically.

func (Size) As

func (u Size) As(other Size) float64

func (*Size) Set

func (u *Size) Set(val string) error

func (Size) String

func (u Size) String() string

Jump to

Keyboard shortcuts

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