Avoid index out of range
1 file changed
tree: 1891755b5fa6c042839fc3e634145ee8baa5d02b
  1. .github/
  2. .travis.yml
  3. LICENSE
  4. README.md
  5. _example/
  6. cmd/
  7. colorable_appengine.go
  8. colorable_others.go
  9. colorable_test.go
  10. colorable_windows.go
  11. go.mod
  12. go.sum
  13. go.test.sh
  14. noncolorable.go
README.md

go-colorable

Build Status Codecov GoDoc Go Report Card

Colorable writer for windows.

For example, most of logger packages doesn‘t show colors on windows. (I know we can do it with ansicon. But I don’t want.) This package is possible to handle escape sequence for ansi color on windows.

Too Bad!

So Good!

Usage

logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
logrus.SetOutput(colorable.NewColorableStdout())

logrus.Info("succeeded")
logrus.Warn("not correct")
logrus.Error("something error")
logrus.Fatal("panic")

You can compile above code on non-windows OSs.

Installation

$ go get github.com/mattn/go-colorable

License

MIT

Author

Yasuhiro Matsumoto (a.k.a mattn)