Documentation
¶
Overview ¶
Package unit contains types and methods for dealing with units of various types. Currently supports metric data units.
Index ¶
Constants ¶
View Source
const ( Byte = DataUnit(1) Kilobyte = Byte * 1000 Megabyte = Kilobyte * 1000 Gigabyte = Megabyte * 1000 Terabyte = Gigabyte * 1000 Petabyte = Terabyte * 1000 )
Supported DataUnit values.
Variables ¶
View Source
var ( // ErrInvalidDataUnit is the error given when parsing a data unit that contains invalid // characters. ErrInvalidDataUnit = errors.New("invalid data unit") // ErrUnknownDataUnit is the error given when parsing a data unit and the unit string does not match // any known units. ErrUnknownDataUnit = errors.New("unknown data unit") )
Functions ¶
This section is empty.
Types ¶
type DataUnit ¶
type DataUnit int
The DataUnit type contains a metric representation of a unit of data, ie bytes, kilobytes etc.
func ParseDataUnit ¶
ParseDataUnit attempts to return a DataUnit corresponding to the provided string. Current values are supported from byte to petabyte:
10B: 10 bytes 10kB: 10 kilobytes 20MB: 20 megabytes 5GB: 5 gigabytes 10TB: 10 terabytes 1PB: 1 petabyte.
Click to show internal directories.
Click to hide internal directories.