Go-ANSI is an ANSI color, style, and cursor manipulation library for golang.
There are a number of golang libraries for dealing with ANSI TTY terminals, but most seem to be too narrowly focused. For example, there are a number of libraries that focus primarily on TTY color, but ignore styles and cursor navigation. Others overly abstract away, and block access to, the lower level ANSI code API.
- https://github.com/mgutz/ansi (Color, Style)
- https://github.com/k0kubun/go-ansi (Color)
- https://github.com/ahmetb/go-cursor (Color, Cursor)
An OSS, liberally licensed (ASL v2), golang library that supports ANSI TTY color, style, and cursor navigation would benefit the golang community by providing a (potentially) commonly used utility.
It should provide:
- A low-level, simple API for dealing with low-level things such as ANSI constants, and functions related to color, style, and cursor navigation. Higher-level components can use this API to create components or widgets such as progress indicators, colorized loggers, etc.
- TTY detection. Provide an API for determining if the output is a an ANSI TTY, and if not, automatically disable ANSI formatting.
- Higher-level, reusable components/widgets such as colorized loggers, CLI applications, etc.
- Plenty of examples for developers to learn from and extend.
The examples Directory provides some example usage:
go run examples/panel/panel.go
go run examples/progress-indicator/progress-indicator.go
go run examples/prompt/prompt.go
go run examples/terminal-screensaver/terminal-screensaver.go
go run examples/unix-info/unix-info.go