News for hackers. Stuff that matters.
Re:Reusable and type-safe options for Go APIs by jopsen on Monday October 23, 2017 @02:54AM (#15531212)
I personally prefer something like:

> type Options struct { ... }

> func myMethod(arg1 string, options Options) {...}

Then have people pass in "Options{}" and let the zero-values imply default.

But most of the time, if you are making things complex, you're missing the whole point of golang. The innovation in golang is it's simplicity, if you miss that, then you might as well code C++ (which have more features for these kinds of things).

There are no comments on this comment yet.