go-color is a simple color library for Go that allows you to print colored text for the Unix terminal.
go install github.com/ermanimer/go-color@latest
// use predefined colors
color.Red.Println("red text")
// create colors with color codes, see the color chart below.
color.New(240).Println("gray text")
// add background color
color.New(220).With(color.Blue).Println("orange text on a blue background")
// create colored strings
fmt.Printf("%s %s\n", color.Green.Paint("green text"), color.Yellow.Paint("with yellow text"))
Output
Color Codes:
Your contribution and feedback are always welcome.