Discover Packages
github.com/opensvc/om3/v3
util
funcopt
package
Version:
v3.0.0-rc52
Opens a new window with list of versions in this module.
Published: Oct 19, 2026
License: Apache-2.0
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: ? modules, 0 packages
The first number is the count of modules that contain a package that imports this one.
The module count is a better indicator of popularity than the package count.
A module with 100 importing packages is counted only once instead of 100 times,
reflecting the fact that the choice to use the package was likely made only once,
not 100 times.
A '?' means that the value hasn't been computed yet.
Opens a new window with list of known importers.
Documentation
Documentation
¶
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
})
}
func Apply(t interface{}, opts ...O ) error
Apply loops over the functional options and executes their setter
function.
type F func(interface{}) error
F is the prototype of the setter function returned by the
option function.
O is the interface that a functional option must implement.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.