Self-referential functions and the design of options

Skip to main content command center Get link Facebook Twitter Pinterest Google+ Email Other Apps January 24, 2014 I've been trying on and off to find a nice way to deal with setting options in a Go package I am writing. Options on a type, that is. The package is intricate and there will probably end up being dozens of options. There are many ways to do this kind of thing, but I wanted one that felt nice to use, didn't require too much API (or at least not too much for the user to absorb), and could grow as needed without bloat. I've tried most of the obvious ways: option structs, lots of methods, variant constructors, and more, and found them all unsatisfactory. After a bunch of trial versions over the past year or so, and a lot of conversat...

Linked on 2018-02-19 21:09:13 | Similar Links