Documentation ¶
Index ¶
- Constants
- Variables
- func AddPath(source string, path string, opts ...source.PathOption) error
- func AddSource(s source.Source) error
- func All() map[string]interface{}
- func Bool(key string, def bool) bool
- func Delete(key string)
- func Duration(key string, def time.Duration) time.Duration
- func Flag(key string, def interface{}, usage string)
- func Float(key string, def float64) float64
- func Get(key string) (value interface{}, ok bool)
- func Init(opts ...Option) (err error)
- func Int(key string, def int) int
- func Keys() []string
- func MustBool(key string) bool
- func MustDuration(key string) time.Duration
- func MustFloat(key string) float64
- func MustInt(key string) int
- func MustString(key string) string
- func MustTime(key string) time.Time
- func Set(key string, value interface{})
- func SetDefault(key string, value interface{})
- func SetLogger(logger log.Logger)
- func Source(name string) (source.Source, error)
- func Sources() []source.Source
- func String(key string, def string) string
- func Time(key string, def time.Time) time.Time
- func Unmarshal(out interface{}, opts ...UnmarshalOption) error
- func Unwatch(id int64)
- func Watch(pattern string, cb EventHandler) (id int64)
- type Event
- type EventHandler
- type Manager
- type Option
- func WithEnvSource(sOpts ...source.Option) Option
- func WithExpandDisabled() Option
- func WithExpansion(pre, post string, cb expander.Handler) Option
- func WithFileSource(requires, optionals []string, sOpts ...source.Option) Option
- func WithFlagSource(sOpts ...source.Option) Option
- func WithLogger(logger log.Logger) Option
- func WithRemoteSource(name string, config *client.Config, sOpts ...source.Option) Option
- type TypeError
- type UnmarshalGet
- type UnmarshalOption
- type Unmarshaler
Constants ¶
View Source
const ( DefaultFilePriority = 0 DefaultEnvPriority = 1 DefaultFlagPriority = 3 DefaultRemotePriority = 9 )
Variables ¶
Event actions
Functions ¶
func Unmarshal ¶
func Unmarshal(out interface{}, opts ...UnmarshalOption) error
Types ¶
type EventHandler ¶
type EventHandler interface {
OnPropertyChange(events []*Event)
}
EventHandler 事件处理
type Manager ¶
type Manager interface { // 添加配置源 AddSource(src source.Source) error Source(name string) (source.Source, error) Sources() []source.Source AddPath(sourceName string, path string, opts ...source.PathOption) error // 配置kv相关操作 All() (values map[string]interface{}) Keys() (keys []string) Get(key string) (value interface{}, ok bool) Set(key string, value interface{}) SetDefault(key string, value interface{}) Delete(key string) // 监听事件 Watch(pattern string, handler EventHandler) (watchId int64) Unwatch(id int64) }
Manager 管理不同的 Source
func NewManager ¶
NewManager create manager instance
type Option ¶
type Option func(opts *options)
func WithEnvSource ¶
func WithExpansion ¶
WithExpansion 指定需要变量替换的模板
func WithFileSource ¶
func WithFlagSource ¶
func WithLogger ¶
type UnmarshalGet ¶
type UnmarshalOption ¶
type UnmarshalOption func(d *decoder)
func WithUnmarshalPrefix ¶
func WithUnmarshalPrefix(key string) UnmarshalOption
func WithUnmarshalTag ¶
func WithUnmarshalTag(tag string) UnmarshalOption
type Unmarshaler ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.