Documentation
¶
Overview ¶
Package humanize formats numeric values for display in user-facing output (stats endpoints, CLI tools, web UIs).
Currently scoped to byte counts (Bytes, BytesSigned). Other unit families (durations, counts) might join later if needs warrant; for now the package stays small and focused on a single rendering convention so every Scrinium-backed surface produces identical output for the same input — a value shown as "1.42 MiB" in one place reads "1.42 MiB" in another, not "1.4 MiB" or "1.42M".
The formatting follows IEC binary units (KiB = 1024 B, MiB = 1024 KiB, ...) with one decimal place above raw bytes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
Bytes renders a byte count in the largest IEC unit that keeps the value under 1024. Format is "<value> <unit>" with one decimal place for KiB and above, no decimal for raw B.
Bytes(0) == "0 B" Bytes(500) == "500 B" Bytes(1500) == "1.5 KiB" Bytes(1<<20) == "1.0 MiB"
Negative input is rendered with its absolute value (no sign). Use BytesSigned for diff/delta contexts where the sign matters.
func BytesSigned ¶
BytesSigned is Bytes with an explicit sign for negative input. Used by diff/delta contexts (heap snapshot deltas after GC, before/after measurements) where direction is meaningful.
BytesSigned(1500) == "1.5 KiB" BytesSigned(-1500) == "-1.5 KiB" BytesSigned(0) == "0 B"
Types ¶
This section is empty.