config

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrTypeCastNotSupported type cast is not supported
	ErrTypeCastNotSupported = errors.New("type cast not supported")

	//ErrNotFound value is not found
	ErrNotFound = errors.New("value not found")
)

Functions

func InitGlobalConfig

func InitGlobalConfig(opts ...Option) error

InitGlobalConfig init global config

Types

type Defaulter

type Defaulter[T any] struct {
	ValueOpt[T]
	Def func() (T, error)
}

Defaulter ...

type IP

type IP struct {
	net.IP
}

IP -

func (IP) MarshalJSON

func (ip IP) MarshalJSON() ([]byte, error)

MarshalJSON -

func (IP) String

func (ip IP) String() string

String -

func (*IP) UnmarshalJSON

func (ip *IP) UnmarshalJSON(b []byte) error

UnmarshalJSON -

type KnownValueTypes

type KnownValueTypes interface {
	time.Time |
		NetCIDR |
		~[]NetCIDR |
		IP |
		~[]IP |
		~int | ~uint |
		~int64 | ~uint64 |
		~int32 | ~uint32 |
		~int16 | ~uint16 |
		~int8 | ~uint8 |
		~float32 | ~float64 |
		~string | ~bool
}

KnownValueTypes ...

type NetCIDR

type NetCIDR struct {
	*net.IPNet
}

func (NetCIDR) MarshalJSON

func (c NetCIDR) MarshalJSON() ([]byte, error)

MarshalJSON -

func (NetCIDR) String

func (c NetCIDR) String() string

String -

func (*NetCIDR) UnmarshalJSON

func (c *NetCIDR) UnmarshalJSON(b []byte) error

UnmarshalJSON -

type OneOf

type OneOf[T any] interface {
	Variants() []T
	Eq(T) bool
}

OneOf -

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option config init option

type Sink

type Sink[T any] struct {
	ValueOpt[T]
	In func(T) error
}

Sink ...

type Value

type Value[T any] interface {
	String() string
	MustValue(ctx context.Context, opts ...ValueOpt[T]) T
	Value(ctx context.Context, opts ...ValueOpt[T]) (T, error)
}

Value config value interface

type ValueOpt

type ValueOpt[T any] interface {
	// contains filtered or unexported methods
}

ValueOpt ...

type ValueT

type ValueT[T any] string

ValueT typed value accessor

func String2ValueT

func String2ValueT[T any](s string) ValueT[T]

String2ValueT ...

func (ValueT[T]) MustValue

func (v ValueT[T]) MustValue(ctx context.Context, opts ...ValueOpt[T]) T

MustValue gets value or panics

func (ValueT[T]) OptDefaulter

func (v ValueT[T]) OptDefaulter(f func() (T, error)) ValueOpt[T]

OptDefaulter ...

func (ValueT[T]) OptSink

func (v ValueT[T]) OptSink(f func(T) error) ValueOpt[T]

OptSink ...

func (ValueT[T]) String

func (v ValueT[T]) String() string

String stringer impl

func (ValueT[T]) Value

func (v ValueT[T]) Value(_ context.Context, opts ...ValueOpt[T]) (ret T, err error)

Value ...

type WithAcceptEnvironment

type WithAcceptEnvironment struct {
	Option
	EnvPrefix string
}

WithAcceptEnvironment option

type WithDefValue

type WithDefValue struct {
	Option
	Key interface{}
	Val interface{}
}

WithDefValue option

type WithSource

type WithSource struct {
	Option
	Source io.Reader
	Type   string
}

WithSource option

type WithSourceFile

type WithSourceFile struct {
	Option
	FileName string
}

WithSourceFile option

Jump to

Keyboard shortcuts

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