Documentation ¶
Index ¶
- type ConfigType
- type FileProvider
- func (p *FileProvider) AddPath(path string)
- func (p *FileProvider) ConfigName() string
- func (p *FileProvider) ConfigType() ConfigType
- func (p *FileProvider) Content() string
- func (p *FileProvider) Get(key string) (interface{}, error)
- func (p *FileProvider) Load() error
- func (p *FileProvider) LoadContent(content string) error
- func (p *FileProvider) NotifyChange() chan bool
- func (p *FileProvider) SetConfigName(configName string)
- func (p *FileProvider) SetConfigType(configType ConfigType)
- func (p *FileProvider) WatchConfig() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigType ¶
type ConfigType string
const ( ConfigTypeYAML ConfigType = "yaml" ConfigTypeJSON ConfigType = "json" )
type FileProvider ¶
type FileProvider struct {
// contains filtered or unexported fields
}
func New ¶
func New() *FileProvider
func (*FileProvider) AddPath ¶
func (p *FileProvider) AddPath(path string)
AddPath adds a path to look for config file. Please don't include filename. Directory only
func (*FileProvider) ConfigName ¶
func (p *FileProvider) ConfigName() string
ConfigName return config file name. The default config file name is "app.yml"
func (*FileProvider) ConfigType ¶
func (p *FileProvider) ConfigType() ConfigType
ConfigType set the config encoding type. Default is "YAML". `YAML`, `JSON` are supported
func (*FileProvider) Content ¶
func (p *FileProvider) Content() string
func (*FileProvider) Get ¶
func (p *FileProvider) Get(key string) (interface{}, error)
func (*FileProvider) Load ¶
func (p *FileProvider) Load() error
Load initialize this package. It will load config into cache and get ready to work. However, if the config file was not found, `ErrFileNotFound` will be returned
func (*FileProvider) LoadContent ¶
func (p *FileProvider) LoadContent(content string) error
LoadContent reads the content as config file
func (*FileProvider) NotifyChange ¶
func (p *FileProvider) NotifyChange() chan bool
NotifyChange return a channel and notify you when file be changed.
func (*FileProvider) SetConfigName ¶
func (p *FileProvider) SetConfigName(configName string)
SetConfigName set a config file name. The default config file name is "app.yml"
func (*FileProvider) SetConfigType ¶
func (p *FileProvider) SetConfigType(configType ConfigType)
SetConfigType set the config encoding type. Default is "YAML". `YAML`, `JSON` are supported
func (*FileProvider) WatchConfig ¶
func (p *FileProvider) WatchConfig() error