🦜 colors

go_version tests coverage docs

screenshot

One more Go library for using colors in the terminal console. The most important features are:

  • ANSI colors support (using Escape Sequences)
  • Multi-thread safe
  • Support FORCE_COLOR, NO_COLOR and TERM variables out of the box
  • Super-lightweight and extremely fast
  • Color codes are not pre-allocated, but cached (in memory) and re-used upon further usage
  • Easy to integrate with the existing code-base

Usage examples

package main

import (
  "fmt"

  "github.com/tarampampam/colors"
)

func main() {
  fmt.Println((colors.FgGreen | colors.Bold).Wrap("green color + bold text"))

  var bg = colors.BgRed

  fmt.Printf("%s red background %s\n", bg.Start(), bg.Reset())

  colors.Enabled(false) // disable colors
  colors.Enabled(true)  // enable colors
}

For more examples see examples directory.

GitHub

View Github