Documentation
¶
Overview ¶
Package color provides ANSI color helpers for CLI output.
Colors are auto-disabled when NO_COLOR is set, stdout is not a TTY, or SetEnabled(false) has been called (via --no-color). All functions return the input string unchanged when colors are disabled, making them safe to use unconditionally.
Table alignment: colored strings contain ANSI escape bytes that are not visible. Use Pad(s, width) instead of %-Ns to produce correctly padded columns from colored strings.
Index ¶
- func Blue(s string) string
- func BlueBold(s string) string
- func Bold(s string) string
- func Cyan(s string) string
- func CyanBold(s string) string
- func Dim(s string) string
- func Enabled() bool
- func Green(s string) string
- func GreenBold(s string) string
- func Pad(s string, width int) string
- func Red(s string) string
- func RedBold(s string) string
- func SetEnabled(v bool)
- func Yellow(s string) string
- func YellowBold(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pad ¶
Pad pads s to at least width visible characters using spaces. Unlike %-Ns format verbs, Pad uses ansi.StringWidth to measure the visible width of s (ignoring ANSI escape sequences), so colored strings align correctly.
func RedBold ¶
RedBold returns s in red and bold. Useful for error keywords like "Error:" or "MISSING".
func SetEnabled ¶
func SetEnabled(v bool)
SetEnabled overrides the auto-detected color state. Call with false to honor the --no-color flag.
func YellowBold ¶
YellowBold returns s in yellow and bold. Useful for warning keywords.
Types ¶
This section is empty.