ansigo
ANSI escape-code library for Golang.
For the colors and attributes, see the project page.
Usage
package main
import (
"fmt"
ansi "github.com/makyo/ansigo"
)
func main() {
bold, err := ansi.Attributes.Find("bold")
if err != nil {
panic(err)
}
fmt.Println(bold.Apply("Some bold text"))
fmt.Print("\n")
red1, err := ansi.Colors8.Find("red")
if err != nil {
panic(err)
}
red2, err := ansi.Colors256.Find("DarkRed")
if err != nil {
panic(err)
}
red3, err := ansi.Colors24bit.Find("#661126")
if err != nil {
panic(err)
}
fmt.Printf("%s %s %s\n", red1.FG("Three"), red2.BG("different"), red3.BG(red1.FG("reds")))
fmt.Print("\n")
s, err := ansi.ApplyOne("underline", "Some text.")
if err != nil {
panic(err)
}
fmt.Println(s)
fmt.Print("\n")
fmt.Println(ansi.MaybeApply("bold+brightyellow+rgb(145, 20, 31):bg+blink", "Warning!"))
}