Documentation ¶
Overview ¶
Package funcopt is a functional options helper package.
Functional options benefits are described at https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
A typical allocator is implemented as:
func New(opts ...funcopt.O) *T { t := &T{<my defaults>} funcopt.Apply(t, opts...) return t }
Example:
func WithName(name string) funcopt.O { return funcopt.F(func(i interface{}) error { t := i.(*T) t.name = name return nil }) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.