config

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is key not found.
	ErrNotFound = errors.New("key not found")
	// ErrTypeAssert is type assert error.
	ErrTypeAssert = errors.New("type assert error")
)

Functions

func NewAtomicValue

func NewAtomicValue() *atomicValue

func NewConfig

func NewConfig(opts ...Option) *config

Types

type Config

type Config interface {
	Load() error              //加载配置文件
	Value(key string) Value   //获取单个key的value
	Scan(v interface{}) error //通过结构体去获取对应的值
}

type Option added in v1.0.2

type Option func(*config)

func WithAllowedExtensions added in v1.0.2

func WithAllowedExtensions(extensions ...string) Option

添加支持的配置文件后缀

func WithConfigPath added in v1.0.2

func WithConfigPath(path string) Option

配置文件路径

type Value

type Value interface {
	Bool() (bool, error)
	Int() (int64, error)
	Float() (float64, error)
	String() (string, error)
	Duration() (time.Duration, error)
}

Jump to

Keyboard shortcuts

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