fatih / color

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

Make enable/disable color chainable #163

Closed Dreamacro closed 1 year ago

Dreamacro commented 2 years ago

It's helpful in reducing unnecessary code, and it does not cause break change.

before

c := color.New(color.FgCyan)
c.EnableColor()
colorStr := c.Sprintf("foo")

after

colorStr := color.New(color.FgCyan).EnableColor().Sprintf("foo")
fatih commented 1 year ago

Thank you @Dreamacro. However, I can't merge this because it breaks the API. It might look like it's NOT causing a change, but the function signature changes in your PR and if there is a code that is passing the EnableColor method around, they will stop working.