Ever wanted colorful output from your Golang CLI projects, but
don't want to have to muck up your codebase with unsightly ANSI
escape sequences?
Then this is the module for you!
Usage
ansi
provides a drop-in replacement for fmt.Printf
and
friends that recognized an additional set of formatter flags for
colorizing output.
import "github.com/jhunt/ansi"
func main() {
err := DoSomething()
if err != nil {
ansi.Printf("error: @R{%s}", err)
}
}
ansi.Fprintf
and ansi.Sprintf
behave similarly, exporting the
exact same call signature as their fmt
bretheren, but handling
the ANSI color sequences for you.
The colorizing formatting codes all look like this:
@ <color> { <text> }
(for the image-averse and search engines:)
@k is Black @K is Black (bold)
@r is Red @R is Red (bold)
@g is Green @G is Green (bold)
@y is Yellow @Y is Yellow (bold)
@b is Blue @B is Blue (bold)
@m is Magenta @M is Magenta (bold)
@c is Cyan @C is Cyan (bold)
@w is White @W is White (bold)
Contributing
- Fork the repo
- Write your code in a feature branch
- Create a new Pull Request