Documentation
¶
Overview ¶
Package format converts typed values into human-readable display strings (times, numbers, byte sizes). It is the output counterpart to internal/parse which converts strings into typed values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
Bytes returns a human-readable byte-size string.
Uses binary units (1024-based): B, KB, MB, GB, etc.
Parameters:
- b: the byte count to format
Returns:
- string: human-readable size with unit
func Duration ¶
Duration returns a human-readable duration string without a suffix.
Parameters:
- d: duration to format
Returns:
- string: human-readable representation (e.g., "3 hours", "1 day", "just now")
func DurationAgo ¶
DurationAgo returns a human-readable duration with an "ago" suffix.
Parameters:
- d: duration to format
Returns:
- string: relative time (e.g., "3 hours ago", "just now")
func Number ¶
Number returns a number with thousand separators.
Examples: 500 → "500", 1500 → "1,500", 12345 → "12,345"
Parameters:
- n: the number to format
Returns:
- string: formatted number with commas
func TimeAgo ¶
TimeAgo returns a human-readable relative time duration.
Examples: "just now", "5 minutes ago", "2 hours ago", "3 days ago", or a formatted date for times older than a week.
Parameters:
- hours: total hours since the event
- mins: total minutes since the event
- fallbackDate: formatted date string for durations older than a week
Returns:
- string: human-readable relative time
func TruncateFirstLine ¶
TruncateFirstLine returns the first line of s, capped at max characters.
Parameters:
- s: Input string (may be multi-line)
- max: Maximum length including ellipsis
Returns:
- string: Truncated first line
Types ¶
This section is empty.