fatih / color

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

When redirect output to the file, the color string will show with unexpected result. #18

Closed zddhub closed 9 years ago

zddhub commented 9 years ago

$ go run color.go > color.log $ vi color.log 1 ^[[36mPrints text in cyan. 2 ^[[0m^[[34mPrints text in blue. 3 ^[[0m^[[31mWe have red 4 ^[[0m^[[35mAnd many others .. 5 ^[[0m

fatih commented 9 years ago

Hi @zddhub . This is normal because it's not interpreted via the shell. Please disable the color if you with a flag like --no-color (https://github.com/fatih/color#disable-color) and use it in the form go run color.go --no-color > color.log