Documentation ¶
Overview ¶
Package oprions provides a way to define and manage options for application components.
Index ¶
- Variables
- func MergeOptions(dest, src *Options) error
- type Arg
- type Kind
- type Option
- type Options
- func (opts *Options) Accepts(key string) bool
- func (opts *Options) Add(spec Spec) error
- func (opts *Options) Describe(key string) string
- func (opts *Options) Get(key string) vars.Variable
- func (opts *Options) Has(key string) bool
- func (opts *Options) Len() int
- func (opts *Options) Load(key string) (vars.Variable, bool)
- func (opts *Options) Name() string
- func (opts *Options) Range(fn func(opt Option) bool)
- func (opts *Options) Seal() error
- func (opts *Options) Set(key string, value any) error
- func (opts *Options) WithPrefix(prefix string) *vars.Map
- type Spec
- type ValueValidator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrOption = errors.New("option error") ErrOptionReadOnly = fmt.Errorf("%w: readonly option", ErrOption) ErrOptionValidation = fmt.Errorf("%w: validation failed", ErrOption) )
Noopvalidator provides no validation for option value.
Functions ¶
func MergeOptions ¶
Types ¶
type Arg ¶
type Arg struct {
// contains filtered or unexported fields
}
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options is general collection of options attached to specific application component.
type Spec ¶ added in v0.2.0
type Spec struct {
// contains filtered or unexported fields
}
Spec holds specification for given option.
type ValueValidator ¶
OptionValueValidator is callback function to validate given value, it recieves copy of value for validation. It MUST return error if validation fails, returned boolean indicates shoulkd that option be marked as radonly if validation succeeds.
Click to show internal directories.
Click to hide internal directories.