fatih / color

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

Doesn't seem to work with go test output #100

Closed ghost closed 5 years ago

ghost commented 6 years ago

I tried using this within a go test function and was not able to get the color in the terminal. It works within a regular main() function.

func Test_Color(t *testing.T) {
    color.Set(color.FgWhite, color.Bold)
    color.Cyan("Prints text in cyan.")
    fmt.Println("This is white in color")
}
fatih commented 5 years ago

Hi,

Unfortunately, I'm archiving this project and will no longer maintaining it. For more information, please read my blog post: Taking an indefinite sabbatical from my projects.

Thanks for the feedback and contribution.

vanta commented 1 year ago

I've faced it today, any chance it can be fixed? I see you still maintain this project @fatih (PRs are being merged)?

davidandradeduarte commented 8 months ago

same here ☝️

davidandradeduarte commented 8 months ago

https://github.com/fatih/color/issues/48#issuecomment-264389137

You have to explicitly set color.NoColor = false so that it works.

This works 😉

fatih commented 8 months ago

Hi folks. Yeah I guess this one got slipped through my archived projects, and yes I'm maintaining this actively. This is really an old issue, so would appreciate to open a new one, with a reproducable case, what you're expecting. Of top of my mind comes that the Testing packages changes the stdout/stderr pipes, so maybe you have to explicitly set that inside the color package. Again would appreciate if you could open a new issue with a reproducible case.