You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Package ansi is a small, fast library to create ANSI colored strings and codes.
Install
Get it
go get -u github.com/mgutz/ansi
Example
import"github.com/mgutz/ansi"// colorize a string, SLOWmsg:=ansi.Color("foo", "red+b:white")
// create a FAST closure function to avoid computation of ANSI codephosphorize:=ansi.ColorFunc("green+h:black")
msg=phosphorize("Bring back the 80s!")
msg2:=phospohorize("Look, I'm a CRT!")
// cache escape codes and build strings manuallylime:=ansi.ColorCode("green+h:black")
reset:=ansi.ColorCode("reset")
fmt.Println(lime, "Bring back the 80s!", reset)
Other examples
Color(s, "red") // redColor(s, "red+d") // red dimColor(s, "red+b") // red boldColor(s, "red+B") // red blinkingColor(s, "red+u") // red underlineColor(s, "red+bh") // red bold brightColor(s, "red:white") // red on whiteColor(s, "red+b:white+h") // red bold on white brightColor(s, "red+B:white+h") // red blink on white brightColor(s, "off") // turn off ansi codes
To view color combinations, from project directory in terminal.