opts

package
v0.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("options: option not found")

ErrNotFound signals that this option is not set.

Functions

This section is empty.

Types

type Opt

type Opt int

Opt is the identifier for the option.

type OptFunc

type OptFunc[K comparable, V any] func(Opts[K, V])

OptFunc is an option

type Options

type Options[K comparable, V any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Options is default options structure.

func (*Options[K, V]) Configure

func (o *Options[K, V]) Configure(opts ...OptFunc[K, V])

Configure os configuring the options.

func (*Options[K, V]) Get

func (o *Options[K, V]) Get(opt Opt) (V, error)

Get is returning the value of the option.

func (*Options[K, V]) Set

func (o *Options[K, V]) Set(opt Opt, v V)

Set is setting the value of the option.

type Opts

type Opts[K comparable, V any] interface {
	// Get ...
	Get(Opt) (V, error)
	// Set ...
	Set(Opt, V)
	// Configure ...
	Configure(...OptFunc[K, V])
}

Opts ...

func New

func New[K comparable, V any](opts ...OptFunc[K, V]) Opts[K, V]

New returns a new instance of the options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL