fatih / color

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

xFunc should return a func w/ identical sig as underlying func #63

Closed maverickwoo closed 7 years ago

maverickwoo commented 7 years ago

The signature of a func returned by, say, color.PrintFunc should be the same as fmt.Print. This enables code usage like:

    f := fmt.Print
    if configColor {
        f = color.New(color.FgRed).PrintFunc()
        // f = color.New(color.FgRed).Print // this is sufficient
    }
    f("foo bar")

P.S. After this patch, I am not sure why the xFunc family of functions are still needed (except for backward compatibility). Maybe we should revise the examples in the documentation to reduce future usage.

fatih commented 7 years ago

Hi @maverickwoo

This came up before but I'm not keen to change the signature of the function. The reason is that it's widely used package and a break like this would cause a lot of problems and problem would break hundreds of thousands projects. Maybe we can do a v2.0 release in the future with these breaking changes. For now though I think we don't need this. Thanks!