Version: v0.0.0-...-f10b52b Latest Latest

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

Go to latest
Published: Jul 26, 2019 License: MIT Imports: 8 Imported by: 0




This section is empty.


View Source
var (
	ErrInvalidOptionValue = errors.New("invalid option value")
	ErrUnsupportedOption  = errors.New("unsupported option")
	ErrOptionNotFound     = errors.New("option not found")



func RegisterOption

func RegisterOption(opt Option, name string, domains []string)

RegisterOption register option

func RegisterStructuredOptions

func RegisterStructuredOptions(opts interface{}, domains []string)

RegisterStructuredOptions register structured options


type AnyOption

type AnyOption interface {
	ValueFrom(optss ...Options) interface{}

AnyOption is option with any value.

func NewAnyOption

func NewAnyOption(val interface{}) AnyOption

NewAnyOption create an any option

type BaseOption

type BaseOption struct {
	// contains filtered or unexported fields

BaseOption is the base of specific options

func (*BaseOption) DefaultValue

func (o *BaseOption) DefaultValue() interface{}

DefaultValue returns the default option value.

func (*BaseOption) String

func (o *BaseOption) String() string

type BoolOption

type BoolOption interface {
	Value(val interface{}) bool
	ValueFrom(optss ...Options) bool

BoolOption is option with bool value.

func NewBoolOption

func NewBoolOption(val bool) BoolOption

NewBoolOption create a bool option

type Int32Option

type Int32Option interface {
	Value(val interface{}) int32
	ValueFrom(optss ...Options) int32

Int32Option is option with int32 value.

func NewInt32Option

func NewInt32Option(val int32) Int32Option

NewInt32Option create an int32 option

type IntOption

type IntOption interface {
	Value(val interface{}) int
	ValueFrom(optss ...Options) int

IntOption is option with int value.

func NewIntOption

func NewIntOption(val int) IntOption

NewIntOption create an int option

type Option

type Option interface {
	String() string
	DefaultValue() interface{}
	Validate(val interface{}) (newVal interface{}, err error)
	Parse(s string) (val interface{}, err error)

Option is an option item.

func ParseOption

func ParseOption(s string) (opt Option, err error)

ParseOption parse Option from string.

type OptionChangeHook

type OptionChangeHook func(opt Option, oldVal, newVal interface{}) error

OptionChangeHook is called when set an option value.

type OptionValues

type OptionValues = map[Option]interface{}

OptionValues is option/value map

type Options

type Options interface {
	SetOption(opt Option, val interface{}) (err error)
	SetOptionIfNotExists(opt Option, val interface{}) (err error)
	AddOptionChangeHook(hook OptionChangeHook) Options

Options is option set.

func NewOptions

func NewOptions() Options

NewOptions create an option set.

func NewOptionsWithAccepts

func NewOptionsWithAccepts(accepts ...Option) Options

NewOptionsWithAccepts create an option set with accepts.

func NewOptionsWithDownStreamsAndAccepts

func NewOptionsWithDownStreamsAndAccepts(downstream Options, accepts ...Option) Options

NewOptionsWithDownStreamsAndAccepts create an option set with down stream and accepts.

func NewOptionsWithValues

func NewOptionsWithValues(ovs OptionValues) Options

NewOptionsWithValues create an option set with option values.

func NewOptionsWithValuesAndSubs

func NewOptionsWithValuesAndSubs(ovs OptionValues, subs ...Options) Options

NewOptionsWithValuesAndSubs create an option set with values and sub options

type ReadOnlyOptions

type ReadOnlyOptions interface {
	GetOption(opt Option) (val interface{}, ok bool)
	GetOptionDefault(opt Option) interface{}
	OptionValues() OptionValues

ReadOnlyOptions is options set read only.

type StringOption

type StringOption interface {
	Value(val interface{}) string
	ValueFrom(optss ...Options) string

StringOption is option with string value.

func NewStringOption

func NewStringOption(val string) StringOption

NewStringOption create a string option

type TimeDurationOption

type TimeDurationOption interface {
	Value(val interface{}) time.Duration
	ValueFrom(optss ...Options) time.Duration

TimeDurationOption is option with time duration value.

func NewTimeDurationOption

func NewTimeDurationOption(name time.Duration) TimeDurationOption

NewTimeDurationOption create a time duration option

type Uint16Option

type Uint16Option interface {
	Value(val interface{}) uint16
	ValueFrom(optss ...Options) uint16

Uint16Option is option with uint16 value.

func NewUint16Option

func NewUint16Option(val uint16) Uint16Option

NewUint16Option create an uint16 option

type Uint32Option

type Uint32Option interface {
	Value(val interface{}) uint32
	ValueFrom(optss ...Options) uint32

Uint32Option is option with uint32 value.

func NewUint32Option

func NewUint32Option(val uint32) Uint32Option

NewUint32Option create an uint32 option

type Uint8Option

type Uint8Option interface {
	Value(val interface{}) uint8
	ValueFrom(optss ...Options) uint8

Uint8Option is option with uint8 value.

func NewUint8Option

func NewUint8Option(val uint8) Uint8Option

NewUint8Option create an uint8 option

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL