Aug 28, 2017 · 1 min read
Another option is to use Go’s support for defining new types based on existing types. Then Add, etc. can be defined based on a named interface such as Field rather the “any” interface{}.
In addition Go’s support for higher-order functions can be used to statically check the number of arguments to Add, etc.
See the following playground for an illustration of both of these.