humanize

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 7 modules, 18 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 provides human-readable representations of numbers, bytes, durations, speed (units/sec), etc.

Index

Constants

View Source
const EraseToEndOfLine = "\033[K"

EraseToEndOfLine is the ANSI control sequence to erase the current line from the cursor to the end.

Variables

This section is empty.

Functions

func Bytes

func Bytes[T ~int64 | ~uint64 | ~int | ~uint | ~int32 | ~uint32 | ~int16 | ~uint16 | ~int8 | ~uint8 | ~uintptr](numAny T) string

Bytes returns the rendering of bytes aproximated to the nearest power of 1024 (Kb, Mb, Gb, Tb, etc.) with one decimal place.

func Count

func Count[T ~int64 | ~uint64 | ~int | ~uint | ~int32 | ~uint32 | ~int16 | ~uint16 | ~int8 | ~uint8 | ~uintptr](numT T) string

Count returns a compact string representation of an integer count appending powers of 1000 suffixes (K, M, G, T, P, E).

func Duration

func Duration(d time.Duration) string

Duration pretty prints duration without a long list of decimal points.

func DurationPerOp added in v0.1.9

func DurationPerOp(elapsed time.Duration, runs int) (value float64, unit string)

DurationPerOp returns the duration per operation split into a float value and unit string (e.g. 12.3 and "µs/op"), suitable for reporting metrics in benchmarks via b.ReportMetric(humanize.DurationPerOp(elapsed, b.N)).

func Speed

func Speed[T ~float64 | ~float32](ratioT T, unit string) string

Speed returns some human readable speed (or ratio) of some unit / second.

func Underscores

func Underscores[T ~int64 | ~uint64 | ~int | ~uint | ~int32 | ~uint32 | ~int16 | ~uint16 | ~int8 | ~uint8 | ~uintptr](numAny T) string

Underscores returns the rendering of an integer with underscores as thousands separators.

Types

This section is empty.

Jump to

Keyboard shortcuts

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