Closed mgeisler closed 8 years ago
Hi @fatih. This is a cut-down version of #34 in case you think it's nice to make people aware of the simpler way to call these functions.
I'm not sure we should dictate person how to use it. No one ever checks the error. I think the current doc is good as it is.
Well, it confused me to see the functions in the library since I had just learnt about the method values :-) Maybe there are others that haven't heard of those and who will be using the Print*Func
methods unnecessarily. So it's not about checking errors, it's about guiding people towards the best and easiest solution.
@mgeisler can you give a real time example on how people use and how you except to be used? I'll merge then if it makes sense, sorry just trying to understand it :)
I guess I'm just imagining that someone would be happy to know that you can do
red := color.Red.Print
instead of
red := color.Red.PrintFunc()
At least for new code where the change in signature isn't a problem. Nothing more than that, really.
Got it, thanks for the explanation. I think the current thing is good. I wish I could change a lot of the API, but the current situation serves well and is used by many other packages. Also note that the signature of red
in your examples are different for both cases. PrintFunc()
returns a function that doesn't has any return values, wheres Print and co are regular print functions. They stil can use them so it's up to them how to use :)
The Print*Func methods can be replaced with a method value in most cases. Method values are supported since Go 1.1:
https://golang.org/doc/go1.1#method_values