daviddengcn/go-colortext: Change the color of console text.
https://github.com/daviddengcn/go-colortext
dixonwille/wlog: A simple logging interface that supports cross-platform color and concurrency.
https://github.com/dixonwille/wlog
package main import ( "strings" "os" . "github.com/dixonwille/wlog" ) func TestWLog() { var ui UI reader := strings.NewReader("User Input ") //Simulate user typing "User Input" then pressing [enter] when reading from os.Stdin ui = New(reader, os.Stdout, os.Stdout) ui = AddConcurrent(ui) var addPrefixCases = []struct { ask string err string inf string log string out string suc string run string war string }{ {" ", " ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " ", " "}, {Cross, Check, "!", "~", "@", "#", "+", "="}, {"%", "^", "&", "*", "@", ":", ",", "?"}, } for _, c := range addPrefixCases { prefix := AddPrefix(c.ask, c.err, c.inf, c.log, c.out, c.run, c.suc, c.war, ui) prefix.Ask("Ask question", "") prefix.Error("Error message") prefix.Info("Info message") prefix.Output("Output message") prefix.Running("Running message") prefix.Success("Success message") prefix.Warn("Warning message") } var addColorCases = []struct { logColor Color outputColor Color successColor Color infoColor Color errorColor Color warnColor Color runningColor Color askColor Color responseColor Color }{ {None, Blue, Green, Red, Yellow, Cyan, Magenta, White, Black}, {BrightBlue, BrightGreen, BrightRed, BrightYellow, BrightCyan, BrightMagenta, BrightWhite, BrightBlack, None}, } for _, c := range addColorCases { color := AddColor(c.askColor, c.errorColor, c.infoColor, c.logColor, c.outputColor, c.responseColor, c.runningColor, c.successColor, c.warnColor, ui) color.Ask("Ask question", "") color.Error("Error message") color.Info("Info message") color.Output("Output message") color.Running("Running message") color.Success("Success message") color.Warn("Warning message") } }