22 lines
504 B
Markdown
22 lines
504 B
Markdown
# Color
|
|
|
|
Supported colors: red, green, yellow, blue, purple, cyan, white, gray
|
|
|
|
```go
|
|
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`).
|