numfmt

package
v0.11.13 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package numfmt provides human-readable formatting for byte counts.

Adapted from github.com/dustin/go-humanize (MIT).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(s uint64, digits int) string

Bytes formats a byte count as a human-readable SI string (base-1000). digits controls significant digits; trailing zeros are always stripped. Below MB, decimals are suppressed.

func BytesWidth

func BytesWidth(s uint64, digits int) int

BytesWidth returns the max formatted width (no zero stripping) for stable padding.

func CountDigits

func CountDigits(n int64) int

CountDigits returns the number of decimal digits in n.

func IBytes

func IBytes(s uint64, digits int) string

IBytes formats a byte count as a human-readable IEC string (base-1024). digits controls significant digits; trailing zeros are always stripped. Below MiB, decimals are suppressed.

func IBytesWidth

func IBytesWidth(s uint64, digits int) int

IBytesWidth returns the max formatted width (no zero stripping) for stable padding.

func TrimDecimalZeros

func TrimDecimalZeros(s string) string

TrimDecimalZeros strips trailing zeros after a decimal point. "100.0" → "100", "82.90" → "82.9", "1.50" → "1.5", "42" → "42".

Types

This section is empty.

Jump to

Keyboard shortcuts

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