Golang ANSI-colors library based on inlined tags.
go get -u github.com/dolab/colorize
package main
import (
"os"
"github.com/pior/colorfmt"
)
func main() {
colorfmt.Printf("{red+bh}-> {yellow+h}Go to {link}%s", "https://wikipedia.com")
colorfmt.Printf(" {white+bh}NOW !!{reset}\n")
text := "{Red+bh}Warning: {yellow}this some color\n"
colorfmt.New(os.Stderr, true).Printf(text) // To stdout
colorfmt.New(os.Stderr, false).Printf(text) // Without color
}Format: fgColor+fgAttributes:bgColor+bgAttributes
Examples:
{red}(red text){yellow:bh}(bold light-yellow text){red+white:h}(red text on light-white background)
Colors:
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- 0...255 (256 colors)
Foreground Attributes:
- B = Blink
- b = bold
- h = high intensity (bright)
- i = inverse
- s = strikethrough
- u = underline
Background Attributes:
- h = high intensity (bright)
Special tags:
{reset}: emit a reset ANSI code to clear all coloring/styling{link}: simulate the style of a clickable hypertext link