Help us shape the future of Go! Take the 2026 Go Developer Survey

convert

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ByteUnitMap map[string]Unit
View Source
var ByteUnits = []Unit{

	{"B", "Byte", 1, 1},
	{"kB", "Kilobyte", 10, 3},
	{"MB", "Megabyte", 10, 6},
	{"GB", "Gigabyte", 10, 9},
	{"TB", "Terabyte", 10, 12},
	{"PB", "Petabyte", 10, 15},
	{"EB", "Exabyte", 10, 18},
	{"ZB", "Zettabyte", 10, 21},
	{"YB", "Yottabyte", 10, 24},

	{"KiB", "Kibibyte", 2, 10},
	{"MiB", "Mebibyte", 2, 20},
	{"GiB", "Gibibyte", 2, 30},
	{"TiB", "Tebibyte", 2, 40},
	{"PiB", "Pebibyte", 2, 50},
	{"EiB", "Exbibyte", 2, 60},
	{"ZiB", "Zebibyte", 2, 70},
	{"YiB", "Yobibyte", 2, 80},
}

Functions

This section is empty.

Types

type Bytesize

type Bytesize struct {
	Data float64
	Unit string
}

func ParseBytes

func ParseBytes(data interface{}) (error, *Bytesize)
Example
err, b := ParseBytes("100MB")
if err != nil {
	panic(err)
}

fmt.Println(b)
fmt.Println(b.ToHumanReadable())
fmt.Println(b.ToKilobyte())
fmt.Println(b.ToGigabyte())
Output:
100 MB
100 MB
100000
0.1

func (*Bytesize) Dump

func (b *Bytesize) Dump()

func (*Bytesize) String

func (b *Bytesize) String() string

func (*Bytesize) ToExabyte

func (b *Bytesize) ToExabyte() float64

func (*Bytesize) ToExbibyte

func (b *Bytesize) ToExbibyte() float64

func (*Bytesize) ToGibibyte

func (b *Bytesize) ToGibibyte() float64

func (*Bytesize) ToGigabyte

func (b *Bytesize) ToGigabyte() float64

func (*Bytesize) ToHumanReadable

func (b *Bytesize) ToHumanReadable() string

func (*Bytesize) ToKibibyte

func (b *Bytesize) ToKibibyte() float64

func (*Bytesize) ToKilobyte

func (b *Bytesize) ToKilobyte() float64

func (*Bytesize) ToMebibyte

func (b *Bytesize) ToMebibyte() float64

func (*Bytesize) ToMegabyte

func (b *Bytesize) ToMegabyte() float64

func (*Bytesize) ToPebibyte

func (b *Bytesize) ToPebibyte() float64

func (*Bytesize) ToPetabyte

func (b *Bytesize) ToPetabyte() float64

func (*Bytesize) ToTebibyte

func (b *Bytesize) ToTebibyte() float64

func (*Bytesize) ToTerabyte

func (b *Bytesize) ToTerabyte() float64

func (*Bytesize) ToYobibyte

func (b *Bytesize) ToYobibyte() float64

func (*Bytesize) ToYottabyte

func (b *Bytesize) ToYottabyte() float64

func (*Bytesize) ToZebibyte

func (b *Bytesize) ToZebibyte() float64

func (*Bytesize) ToZettabyte

func (b *Bytesize) ToZettabyte() float64

type Unit

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

Jump to

Keyboard shortcuts

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