format

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package format provides shared formatting utilities for numeric values and strings. It handles formatting of bytes (with binary prefixes), percentages, time durations, generic numeric values with SI suffixes (K, M, G, T), and string truncation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(bytes float64) string

Bytes formats bytes to human-readable form using binary prefixes (1024).

func BytesShort

func BytesShort(bytes float64) string

BytesShort formats bytes to short human-readable form for axis labels.

func Truncate added in v0.7.0

func Truncate(s string, maxLen int) string

Truncate truncates a string to maxLen characters with ellipsis. If the string is shorter than maxLen, it is returned unchanged.

func Value

func Value(value float64, units string) string

Value formats a numeric value with appropriate units. Handles percentages, bytes, time units, and generic values.

func YAxisValue

func YAxisValue(value float64, units string) string

YAxisValue formats a value for Y axis labels with appropriate SI suffixes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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