xcfg

package module
v0.0.0-...-ae65b4c Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFileName   = "config"
	DefaultSearchPath = []string{".", "config"}
)

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Init(c *Config) error
}

type Config

type Config struct {
	// contains filtered or unexported fields
}

func New

func New(adapter Adapter, watchers ...Watcher) (*Config, error)

New 返回一个配置对象

func (*Config) AddWatcher

func (c *Config) AddWatcher(watcher ...Watcher)

AddWatcher 添加监听处理

func (*Config) AllKeys

func (c *Config) AllKeys() []string

func (*Config) AllSettings

func (c *Config) AllSettings() map[string]interface{}

func (*Config) Get

func (c *Config) Get(key string, def ...interface{}) interface{}

func (*Config) GetBool

func (c *Config) GetBool(key string, def ...interface{}) bool

func (*Config) GetDuration

func (c *Config) GetDuration(key string, def ...interface{}) time.Duration

func (*Config) GetFloat64

func (c *Config) GetFloat64(key string, def ...interface{}) float64

func (*Config) GetInt

func (c *Config) GetInt(key string, def ...interface{}) int

func (*Config) GetInt32

func (c *Config) GetInt32(key string, def ...interface{}) int32

func (*Config) GetInt64

func (c *Config) GetInt64(key string, def ...interface{}) int64

func (*Config) GetIntSlice

func (c *Config) GetIntSlice(key string, def ...interface{}) []int

func (*Config) GetSizeInBytes

func (c *Config) GetSizeInBytes(key string, def ...interface{}) uint

func (*Config) GetString

func (c *Config) GetString(key string, def ...interface{}) string

func (*Config) GetStringMap

func (c *Config) GetStringMap(key string, def ...interface{}) map[string]interface{}

func (*Config) GetStringMapString

func (c *Config) GetStringMapString(key string, def ...interface{}) map[string]string

func (*Config) GetStringMapStringSlice

func (c *Config) GetStringMapStringSlice(key string, def ...interface{}) map[string][]string

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(key string, def ...interface{}) []string

func (*Config) GetTime

func (c *Config) GetTime(key string, def ...interface{}) time.Time

func (*Config) GetUint

func (c *Config) GetUint(key string, def ...interface{}) uint

func (*Config) GetUint32

func (c *Config) GetUint32(key string, def ...interface{}) uint32

func (*Config) GetUint64

func (c *Config) GetUint64(key string, def ...interface{}) uint64

func (*Config) IsSet

func (c *Config) IsSet(key string) bool

IsSet 判断key是否存在

func (*Config) MergeConfig

func (c *Config) MergeConfig(in io.Reader) error

func (*Config) MergeConfigMap

func (c *Config) MergeConfigMap(cfg map[string]interface{}) error

func (*Config) SafeWriteConfig

func (c *Config) SafeWriteConfig() error

func (*Config) SafeWriteConfigAs

func (c *Config) SafeWriteConfigAs(filename string) error

func (*Config) Set

func (c *Config) Set(key string, value interface{})

func (*Config) SetDefault

func (c *Config) SetDefault(key string, value interface{})

func (*Config) Sub

func (c *Config) Sub(key string) *Config

Sub 返回一个子配置对象

func (*Config) Unmarshal

func (c *Config) Unmarshal(rawVal interface{}, opts ...viper.DecoderConfigOption) error

func (*Config) UnmarshalKey

func (c *Config) UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error

func (*Config) Viper

func (c *Config) Viper() *viper.Viper

Viper 返回 *viper.Viper 对象

func (*Config) Wait

func (c *Config) Wait()

Wait 等待

func (*Config) Watch

func (c *Config) Watch()

Watch 处理监听

func (*Config) WriteConfig

func (c *Config) WriteConfig() error

func (*Config) WriteConfigAs

func (c *Config) WriteConfigAs(filename string) error

type Content

type Content struct {
	Type    string
	Content string
}

Content 文本内容配置

func (Content) Init

func (f Content) Init(c *Config) error

type File

type File struct {
	File string
	Type string
	Name string
	Path []string
}

File 本地文件配置

func (File) Init

func (f File) Init(c *Config) error

type Remote

type Remote struct {
	Provider string
	Endpoint string
	Type     string
	Path     string
	Key      string
}

Remote 远程配置

func (Remote) Init

func (f Remote) Init(c *Config) error

type Watcher

type Watcher func(c *Config) error

func UnmarshalWatcher

func UnmarshalWatcher(val interface{}, key ...string) Watcher

UnmarshalWatcher 默认watcher

Jump to

Keyboard shortcuts

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