Documentation
¶
Overview ¶
Package format provides shared formatting helpers for display values.
Index ¶
- func Bytes(b float64) string
- func Cost(dollars float64) string
- func Count(n int64) string
- func FirstSentence(text string) string
- func Percent(fraction float64) string
- func TitleCase(slug string) string
- func Volume(eventsPerHour float64) string
- func YearlyCost(costPerHour float64) string
- func YearlyCostPtr(costPerHour *float64) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstSentence ¶ added in v1.18.0
FirstSentence returns the first sentence of text (up to ". " or "; "), or the first 120 characters with a word-boundary cutoff if no sentence break is found.
func Percent ¶ added in v1.18.0
Percent formats a fraction as a percentage: 0.68 → "68%", 0.004 → "<1%".
func TitleCase ¶
TitleCase converts a snake_case slug to Title Case. "bot_traffic" → "Bot Traffic", "pii_leakage" → "Pii Leakage".
func YearlyCost ¶
YearlyCost formats an hourly USD rate as yearly: $0/yr, $1.7k/yr, $110k/yr.
func YearlyCostPtr ¶ added in v1.18.0
YearlyCostPtr formats a nullable hourly rate: nil → "—", 0 → "$0/yr", positive → "~$1.7k/yr". Use this at display boundaries where the value may not yet be estimated (nil) vs estimated at zero.
Types ¶
This section is empty.