config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 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

Types

type Config

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

type Configure added in v1.2.0

type Configure struct {
	V *viper.Viper //viper
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(opts ...Option) *Configure

func (*Configure) Load added in v1.2.0

func (c *Configure) Load() error

func (*Configure) LoadALLValue added in v1.2.0

func (c *Configure) LoadALLValue()

func (*Configure) Scan added in v1.2.0

func (c *Configure) Scan(v interface{}) error

func (*Configure) ScanLocalConfig added in v1.2.0

func (c *Configure) ScanLocalConfig() ([]string, error)

扫描本地配置

func (*Configure) Value added in v1.2.0

func (c *Configure) Value(key string) Value

type Option added in v1.0.2

type Option func(*Configure)

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 PlaceholderReplacer added in v1.2.0

type PlaceholderReplacer func(string) string

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