humanize

package
v2.3.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

package humanize is designed to parse and format "humanized" versions of numbers with units.

Based on: github.com/dustin/go-humanize.

Index

Constants

View Source
const (
	Byte = 1 << (iota * 10)
	Kibibyte
	Mebibyte
	Gibibyte
	Tebibyte
	Pebibyte

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

Variables

This section is empty.

Functions

func FormatBytes

func FormatBytes(s uint64) string

FormatBytes outputs the given number of bytes "s" as a human-readable string, rounding to the nearest half within .01.

func FormatBytesUnit

func FormatBytesUnit(s, u uint64) string

FormatBytesUnit outputs the given number of bytes "s" as a quantity of the given units "u" to the nearest half within .01.

func ParseByteUnit

func ParseByteUnit(str string) (uint64, error)

ParseByteUnit returns the number of bytes in a given unit of storage, or an error, if that unit is unrecognized.

func ParseBytes

func ParseBytes(str string) (uint64, error)

ParseBytes parses a given human-readable bytes or ibytes string into a number of bytes, or an error if the string was unable to be parsed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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