Coloured terminal output for Go with ANSI escape codes
open sourceMITfree
color is a Go package for printing coloured and styled text to the terminal with ANSI escape codes, and it works on Windows too. It has helper functions for the standard colours, 24-bit RGB foreground and background colours when the terminal supports them, and colour objects you can combine with attributes such as bold and underline and reuse across your program.
Problems it solves
- print coloured error and success messages from my Go command-line tool
- make terminal output from a Go program bold or underlined
- colour output in a Go CLI so it also works on Windows terminals
Features
- standard colour helpers
- 24-bit RGB colours
- combinable attributes like bold and underline
- reusable colour objects
- Windows support
Alternatives
The same job
These do what color (Go) does.
- go-colorable Colorable writer for Windows
- Lip Gloss Style definitions for nice terminal layouts
- go-isatty isatty for Go: tell whether output goes to a terminal
- tablewriter Text tables for Go in ASCII, Unicode, Markdown or HTML
