fatih / color

Color package for Go (golang)
https://pkg.go.dev/github.com/fatih/color
MIT License
7.24k stars 615 forks source link

Expose colorable Stderr to use as writer #87

Closed achilleas-k closed 6 years ago

achilleas-k commented 6 years ago

Since printing colors on Windows requires defining the colorised writer (fmt.Fprint(color.Output, ...)), this PR exposes the equivalent colorised Stderr writer. So the following would be supported:

var green = color.New(color.FgGreen).SprintFunc()
var red = color.New(color.FgRed).SprintFunc()

fmt.Fprintln(color.Output, green("This is normal green text")) // Prints to os.Stdout
fmt.Fprintln(color.Output, red("This is normal red text")) // Prints to os.Stdout
fmt.Fprintln(color.Error, red("This is error red text"))  // Prints to os.Stderr
fatih commented 6 years ago

Thanks @achilleas-k