color

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 5 Imported by: 0

README

Color

Supported colors: red, green, yellow, blue, purple, cyan, white, gray

fmt.Print(color.Blue("Blue text"))
fmt.Printf("Status: %s\n", color.Green("OK"))
fmt.Println(color.Red("Error occurred"))

blue := color.Blue("Blue text")
warning := color.Yellow("Warning message")

color.SetColors(false)
color.SetColors(true)

if color.ColorsEnabled() {
    // ...
}

Colors are automatically detected based on terminal capabilities and environment variables (NO_COLOR, FORCE_COLOR, TERM).

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Reset  = makeColorFunc(resetCode)
	Red    = makeColorFunc(redCode)
	Green  = makeColorFunc(greenCode)
	Yellow = makeColorFunc(yellowCode)
	Blue   = makeColorFunc(blueCode)
	Purple = makeColorFunc(purpleCode)
	Cyan   = makeColorFunc(cyanCode)
	White  = makeColorFunc(whiteCode)
	Gray   = makeColorFunc(grayCode)
)

Color function; makes a call to makeColorFunc with the associated color code

Functions

func ColorsEnabled added in v1.1.0

func ColorsEnabled() bool

ColorsEnabled returns current global color setting

func DetectShellColors added in v1.1.0

func DetectShellColors() bool

DetectShellColors checks if the current shell supports colors

func SetColors added in v1.1.0

func SetColors(enabled bool)

SetColors enables or disables colors globally

Types

This section is empty.

Jump to

Keyboard shortcuts

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