datasize

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2015 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Overview

Package datasize implements a type representing data sizes in bytes.

Index

Constants

View Source
const (
	Kilobyte Size = 1000 * Byte
	Megabyte      = 1000 * Kilobyte
	Gigabyte      = 1000 * Megabyte
	Terabyte      = 1000 * Gigabyte
	Petabyte      = 1000 * Terabyte
)

Common decimal data sizes

View Source
const (
	Byte     Size = 1
	Kibibyte      = 1024 * Byte
	Mebibyte      = 1024 * Kibibyte
	Gibibyte      = 1024 * Mebibyte
	Tebibyte      = 1024 * Gibibyte
	Pebibyte      = 1024 * Tebibyte
)

Common binary data sizes

Variables

This section is empty.

Functions

This section is empty.

Types

type Size

type Size uint64

Size represents the size of data in bytes.

func Flag

func Flag(name, value, description string) *Size

Flag defines a Size flag with specified name, default value, and usage string.

func Parse

func Parse(s string) (Size, error)

Parse parses a Size from a string. A Size is an unsigned decimal number with an optional fraction and a unit suffix. Examples: "0", "10B", "1kB", "4GB", "5GiB". Valid units are "B", (decimal: "kB", "MB", "GB, "TB, "PB"), (binary: "KiB", "MiB", "GiB", "TiB", "PiB")

func (Size) Bytes

func (s Size) Bytes() uint64

Bytes returns s in the equivalent number of bytes.

func (Size) Gibibytes

func (s Size) Gibibytes() float64

Gibibytes returns s in the equivalent number of gibibytes.

func (Size) Gigabytes

func (s Size) Gigabytes() float64

Gigabytes returns s in the equivalent number of gigabytes.

func (Size) Kibibytes

func (s Size) Kibibytes() float64

Kibibytes returns s in the equivalent number of kibibytes.

func (Size) Kilobytes

func (s Size) Kilobytes() float64

Kilobytes returns s in the equivalent number of kilobytes.

func (Size) Mebibytes

func (s Size) Mebibytes() float64

Mebibytes returns s in the equivalent number of mebibytes.

func (Size) Megabytes

func (s Size) Megabytes() float64

Megabytes returns s in the equivalent number of megabytes.

func (Size) Pebibytes

func (s Size) Pebibytes() float64

Pebibytes returns s in the equivalent number of pebibytes.

func (Size) Petabytes

func (s Size) Petabytes() float64

Petabytes returns s in the equivalent number of petabytes.

func (Size) String

func (s Size) String() string

String implements the Stringer interface.

func (Size) Tebibytes

func (s Size) Tebibytes() float64

Tebibytes returns s in the equivalent number of tebibytes.

func (Size) Terabytes

func (s Size) Terabytes() float64

Terabytes returns s in the equivalent number of terabytes.

Jump to

Keyboard shortcuts

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