configx

package
v5.0.0-...-ad4f444 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Walk

func Walk(keys []string, current any, fn func(i int, v any) (bool, error)) error

Types

type Caster

type Caster interface {
	Bool() bool
	Bytes() []byte
	Interface() interface{}
	Int() int
	Int64() int64
	Duration() time.Duration
	String() string
	StringMap() map[string]string
	StringArray() []string
	Slice() []interface{}
	Map() map[string]interface{}
	Scanner
}

type Decrypter

type Decrypter interface {
	Decrypt(string) ([]byte, error)
}

type Encrypter

type Encrypter interface {
	Encrypt([]byte) (string, error)
}

type Getter

type Getter func() any

type Marshaller

type Marshaller interface {
	Marshal(interface{}) ([]byte, error)
}

type Option

type Option func(*Options)

func WithBinary

func WithBinary() Option

func WithDecrypt

func WithDecrypt(d Decrypter) Option

func WithEncrypt

func WithEncrypt(e Encrypter) Option

func WithInitData

func WithInitData(data interface{}) Option

func WithJSON

func WithJSON() Option

func WithMarshaller

func WithMarshaller(m Marshaller) Option

func WithReadOnly

func WithReadOnly() Option

func WithReferencePool

func WithReferencePool(key string, ref *openurl.Pool[Values]) Option

func WithSetCallback

func WithSetCallback(f func([]string, interface{}) error) Option

func WithStorer

func WithStorer(data Storer) Option

func WithString

func WithString() Option

func WithUnmarshaler

func WithUnmarshaler(u Unmarshaler) Option

func WithYAML

func WithYAML() Option

type Options

type Options struct {
	InitData interface{}

	Storer

	Unmarshaler
	Marshaller
	Encrypter
	Decrypter

	// Additional callback after Set is called
	SetCallback func([]string, interface{}) error

	// Do not create any resources
	ReadOnly bool

	ReferencePool map[string]*openurl.Pool[Values]

	// Used to pass other potential options
	Context context.Context
}

type Ref

type Ref struct {
	Ref string `json:"$ref"`
}

func Reference

func Reference(ref string) *Ref

type Scanner

type Scanner interface {
	Scan(out any, options ...Option) error
}

type Storer

type Storer interface {
	Context(ctx context.Context) Values
	Options() *Options
	Key() []string
	Val(path ...string) Values
	Default(def any) Values
	Get(...WalkOption) any
	Set(value any) error
	Del() error
}

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte, interface{}) error
}

type Values

type Values interface {
	Storer
	Caster
}

func New

func New(opts ...Option) (ret Values)

type WalkOption

type WalkOption func(*WalkOptions)

func WithInterceptor

func WithInterceptor(f func(i int, v any) (bool, any)) WalkOption

type WalkOptions

type WalkOptions struct {
	Interceptor func(i int, v any) (bool, any)
}

Jump to

Keyboard shortcuts

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