color

package
v1.24.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 3 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blue

func Blue(s string) string

Blue returns s in bright blue, or s unchanged if colors are disabled.

func BlueBold

func BlueBold(s string) string

BlueBold returns s in blue and bold. Useful for agent name headers.

func Bold

func Bold(s string) string

Bold returns s in bold, or s unchanged if colors are disabled.

func Cyan

func Cyan(s string) string

Cyan returns s in bright cyan, or s unchanged if colors are disabled.

func CyanBold

func CyanBold(s string) string

CyanBold returns s in cyan and bold. Useful for section headers.

func Dim

func Dim(s string) string

Dim returns s in dim/faint style, or s unchanged if colors are disabled.

func Enabled

func Enabled() bool

Enabled reports whether color output is currently active.

func Green

func Green(s string) string

Green returns s in bright green, or s unchanged if colors are disabled.

func GreenBold

func GreenBold(s string) string

GreenBold returns s in green and bold. Useful for success summaries.

func Pad

func Pad(s string, width int) string

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 Red

func Red(s string) string

Red returns s in bright red, or s unchanged if colors are disabled.

func RedBold

func RedBold(s string) string

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 Yellow

func Yellow(s string) string

Yellow returns s in bright yellow, or s unchanged if colors are disabled.

func YellowBold

func YellowBold(s string) string

YellowBold returns s in yellow and bold. Useful for warning keywords.

Types

This section is empty.

Jump to

Keyboard shortcuts

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