package units

import "github.com/google/cadvisor/Godeps/_workspace/src/github.com/docker/go-units"

Package units provides helper function to parse and print size and time units in human-readable format.

Index

Constants

const (
	KB = 1000
	MB = 1000 * KB
	GB = 1000 * MB
	TB = 1000 * GB
	PB = 1000 * TB

	KiB = 1024
	MiB = 1024 * KiB
	GiB = 1024 * MiB
	TiB = 1024 * GiB
	PiB = 1024 * TiB
)

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

Functions

func BytesSize

func BytesSize(size float64) string

BytesSize returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").

func CustomSize

func CustomSize(format string, size float64, base float64, _map []string) string

CustomSize returns a human-readable approximation of a size using custom format.

func FromHumanSize

func FromHumanSize(size string) (int64, error)

FromHumanSize returns an integer from a human-readable specification of a size using SI standard (eg. "44kB", "17MB").

func HumanDuration

func HumanDuration(d time.Duration) string

HumanDuration returns a human-readable approximation of a duration (eg. "About a minute", "4 hours ago", etc.).

func HumanSize

func HumanSize(size float64) string

HumanSize returns a human-readable approximation of a size capped at 4 valid numbers (eg. "2.746 MB", "796 KB").

func RAMInBytes

func RAMInBytes(size string) (int64, error)

RAMInBytes parses a human-readable string representing an amount of RAM in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and returns the number of bytes, or -1 if the string is unparseable. Units are case-insensitive, and the 'b' suffix is optional.

Types

type Rlimit

type Rlimit struct {
	Type int    `json:"type,omitempty"`
	Hard uint64 `json:"hard,omitempty"`
	Soft uint64 `json:"soft,omitempty"`
}

Rlimit specifies the resource limits, such as max open files.

type Ulimit

type Ulimit struct {
	Name string
	Hard int64
	Soft int64
}

Ulimit is a human friendly version of Rlimit.

func ParseUlimit

func ParseUlimit(val string) (*Ulimit, error)

ParseUlimit parses and returns a Ulimit from the specified string.

func (*Ulimit) GetRlimit

func (u *Ulimit) GetRlimit() (*Rlimit, error)

GetRlimit returns the RLimit corresponding to Ulimit.

func (*Ulimit) String

func (u *Ulimit) String() string

Source Files

duration.go size.go ulimit.go

Version
v0.23.7
Published
Jul 18, 2016
Platform
js/wasm
Imports
5 packages
Last checked
49 minutes ago

Tools for package owners.