+
Skip to content

bbkane/gocolor

Repository files navigation

gocolor

TestWithReflection.png

A tiny cross-platform terminal color library that supports enabling and disabling colors.

Uses colors from https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences?redirectedfrom=MSDN#text-formatting

Tested on macOS and (occasionally) on Ubuntu 20 and Windows 10.

Project Status (2025-06-14)

Basically complete! gocolor works for my simple use cases. I'm watching issues; please open one for any questions and especially BEFORE submitting a Pull request.

Usage

color, err := gocolor.Prepare(true)
if err != nil {
  panic(err)
}

fmt.Println(
  color.Add(color.FgRed, "FgRed"),
  color.Add(color.FgCyanBright+color.Negative, "FgCyanBright+Negative"),
)

See tests for inspiration.

I use mattn/go-isatty to test my programs before enabling this.

See Go Project Notes for notes on development tooling.

Inspirations

About

Tiny cross-platform terminal color library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载