fatih / color

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

Return objects implementing Fmt.Formatter. #70

Closed prataprc closed 5 years ago

prataprc commented 7 years ago

Right now, if we are going to use Sprint, Sprintf, Sprintln outputs and perform further formatting on the returned string as:

    fmt.Printf("%-10s", color.New(color.FgYellow).Sprint("hello"))

it may not give the correct padding.

To handle such cases, implement a set of functions that can return formattable objects outside color/ package.

To begin with, I might propose the following:

Implement a set of functions similar to Sprint, Sprintf, Sprintln. And another set of functions similar to SprintFunc, SprintfFunc SprintlnFunc that returns an object implementing fmt.Formatter{} interface.

If it make sense, I can do a draft implementation and raise a pull request.

Thanks,

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.