config

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLoaderUndefined = fmt.Errorf("loader undefined")
	ErrPathUndefined   = fmt.Errorf("path undefined")
	ErrPathNotFound    = fmt.Errorf("path not found")
	ErrPathNoContent   = fmt.Errorf("path has no content")
	ErrPathUnavailable = fmt.Errorf("path unavailable")
	ErrPathNotFile     = fmt.Errorf("only accepts single file, but got directory")
)

Functions

func Clear

func Clear()

func LoadConfigs

func LoadConfigs(configPath string) error

func Use

func Use(l Loader) error

Types

type CtxConfigDecoder

type CtxConfigDecoder interface {
	DecodeConfig(context.Context, Value) error
}

type CtxDecoder

type CtxDecoder interface {
	Decode(context.Context, Value) error
}

type Decoder

type Decoder interface {
	Decode(Value) error
}

type Iterator

type Iterator interface {
	Next() bool
	Value() Value
	Label() string
}

type Kind

type Kind uint8
const (
	UndefinedKind Kind = iota
	NullKind
	BoolKind
	StringKind
	BytesKind
	StructKind
	ListKind
	NumberKind
	DecimalKind
)

func (Kind) String

func (k Kind) String() string

type Loader

type Loader interface {
	Type() string
	AllowDir() bool
	PathPattern() *regexp.Regexp
	Load(path string, files map[string][]byte) (Value, error)
	Clear()
}

type Value

type Value interface {
	Decode(interface{}) error
	DecodeWithCtx(context.Context, interface{}) error
	String() (string, error)
	Bytes() ([]byte, error)
	Bool() (bool, error)
	Float64() (float64, error)
	Int64() (int64, error)
	Uint64() (uint64, error)
	Interface() (interface{}, error)
	Ref() string
	File() string
	Lookup(path ...string) (Value, bool)
	List() (Iterator, error)
	StringList() ([]string, error)
	Struct() (Iterator, error)
	Kind() Kind
	Marshal() ([]byte, error)
}

func Lookup

func Lookup(fieldPath ...string) (Value, bool)

func Root added in v0.0.2

func Root() Value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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