Documentation
¶
Overview ¶
Package optionutil provides utility functions for working with options.Context.
Index ¶
- func Append[T any](ctx options.Context, values ...T) options.Context
- func Apply[T any](cfg *T, opts ...options.Option) options.Context
- func Default() options.Context
- func Empty() options.Context
- func New[T any](opts ...options.Option) (options.Context, *T)
- func NewContext[T any](opts ...options.Option) options.Context
- func NewT[T any](opts ...options.Option) *T
- func Slice[T any](ctx options.Context) []T
- func SliceCond[T any](ctx options.Context, condition func([]T) bool) []T
- func SliceOr[T any](ctx options.Context, defaultValue []T) []T
- func Update[T any](updaters ...func(*T)) options.Option
- func Value[T any](ctx options.Context) (T, bool)
- func ValueCond[T any](ctx options.Context, condition func(T) bool, defaultValue T) T
- func ValueOr[T any](ctx options.Context, defaultValue T) T
- func WithCond(condition bool, opt options.Option) options.Option
- func WithContext(ctx options.Context) options.Option
- func WithGroup(opts ...options.Option) options.Option
- func WithValue[T any](ctx options.Context, value T) options.Context
- type Key
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a new instance of T, applies options, and returns both the final context and the configured instance.
func NewContext ¶
NewContext creates a new instance of T, applies options, and returns the resulting context.
func Update ¶
Update returns an options.Option that modifies a configuration struct *T using an implicit key.
func WithCond ¶
WithCond returns an options.Option that applies the given options.Option if the condition is true.
func WithContext ¶
WithContext returns an options.Option that sets the given options.Context as the current context.
Types ¶
Click to show internal directories.
Click to hide internal directories.