fatih / color

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

Library does not work in GitHub Actions #132

Closed marwan-at-work closed 3 years ago

marwan-at-work commented 3 years ago

Hi there Fatih 👋🏼

So I'm not totally sure why, but if I run color.Yellow("HELLO") from inside GitHub Actions, no color is actually printed.

But if I use another library such as aurora/v3 and write fmt.Println(aurora.Sprintf(aurora.Magenta("OK?"))), a color is actually printed in the Actions UI.

I definitely prefer this library for its nice API :)

I'll try to dig into it more if I get some free time, but thought I'd bring it up in case anyone is curious to dig into this before me.

Thanks!

fatih commented 3 years ago

Hi @marwan-at-work

I assume it's due to the automatic color detection here:

https://github.com/fatih/color/blob/master/color.go#L20

Can you explicitly set it to false to bypass the check: color.NoColor = false and try again? The check is there to avoid mangling the input to a tool during a pipe operation.

marwan-at-work commented 3 years ago

Yep, color.NoColor = false did the trick. Thank you for the quick response 🙌🏼

Added a quick PR to mention this in the README.

Hope you're well 👍🏼

fatih commented 3 years ago

Thanks for the documentation in the Readme @marwan-at-work. Everything is fine on my end and I hope things are also going great for you :)