color 
DEPRECATED
Color extends fmt.Printf
with verbs for producing colored output.
It has full terminfo support with github.com/nhooyr/terminfo!
note: things may change but it looks pretty stable. email me if you have any new ideas.
Install
go get github.com/nhooyr/color
Examples
See godoc for more information.
Setting Attributes
color.Printf("%h[fgRed]panic:%r %s\n", "foo")
color.Printf("%h[bgRed]panic:%r %s\n", "bar")
color.Printf("%h[bold]panic:%r %s\n", "foo")
color.Printf("%h[underline]panic:%r %s\n", "bar")
color.Printf("%h[fg83]panic:%r %s\n", "foo")
color.Printf("%h[bg158]panic:%r %s\n", "bar")
Mixing Attributes
color.Printf("%h[fgGreen+bold]panic:%r %s\n", "foo")
color.Printf("%h[bg8+underline]panic:%r %s\n", "bar")
Prepare
panicFormat := color.Prepare("%h[fgRed+bold]panic:%r %s\n")
color.Printfp(panicFormat, "foo")
color.Printfp(panicFormat, "bar")
color.Printfp(panicFormat, "foo")
hello := color.Prepare("%h[fgBlue+bold]HELLO%r")
color.Println(hello)
color.Println(hello)
color.Println(hello)
Printer
A Printer
writes to an io.Writer
.
redFormat := color.Prepare("%h[fgRed]%s%r\n")
p := color.New(os.Stderr, color.IsTerminal(os.Stderr))
p.Printfp(redFormat, "bar")
p = color.New(os.Stderr, true)
p.Printfp(redFormat, "foo")
p = color.New(os.Stderr, false)
p.Printfp(redFormat, "bar")
github.com/nhooyr/color/log
redFormat := color.Prepare("%h[fgRed]%s%r\n")
log.Printfp(redFormat, "foo")
log.SetColor(false)
log.Printfp(redFormat, "bar")
log.SetColor(true)
log.Fatalfp(redFormat, "foo")
Vim syntax highlighting
Add the following to after/syntax/go.vim
to highlight the highlight verbs within strings.
syn match goFormatSpecifier /%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)*\%([vTtbcdoqxXUeEfgGspr]\|h\[[a-zA-Z+0-9]\+\]\)/ contained containedin=goString
TODO