humanize

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2017 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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