Closed itchyny closed 1 year ago
Hi @itchyny this looks like something we can do. Let me think about this a little bit. Thank you for your feedback.
I would be happy to implement this. What do you think about implementing io.Writer
as well? It would enable one to wrap any writer with a color, and use it in the existing code without changing anything.
I'm ok with only exporting the two functions. Currently I use go:linkname
to call color.(*Color).setWriter
. I'm not sure what lib users would expect when they nest coloring writers.
I'm in same boat as @itchyny.
I am working with bytes and io.Writer
and the print functions (as easy and convenient as they are) do not suit my use case.
This is fixed now, I'm going to release a new version soon with the fields being exported. Sorry for the late changes on this, 2021 was when I moved back from the US to Turkey, and I'm slowly going over my some of my OSS work.
Now
color.Set
andcolor.Unset
are exported so that we can color output to the standard output. Can you exportcolor.SetWriter
andcolor.UnsetWriter
? This is pretty useful when we cannot change the code to Fprint style. Also usingw.Write
beats Fprint* functions in performance because it does not scan for formatting.