Documentation ¶
Index ¶
- type Conf
- func (cnf *Conf) Delete(key string) *Conf
- func (cnf *Conf) Get(key string) interface{}
- func (cnf *Conf) GetAll() map[string]interface{}
- func (cnf *Conf) GetBool(key string) bool
- func (cnf *Conf) GetFloat64(key string) float64
- func (cnf *Conf) GetInt(key string) int
- func (cnf *Conf) GetMapKeys(key string) []string
- func (cnf *Conf) GetParent(name string) *Conf
- func (cnf *Conf) GetString(key string) string
- func (cnf *Conf) GetStrings(key string) []string
- func (cnf *Conf) Has(key string) bool
- func (cnf *Conf) Load(val map[string]interface{}) *Conf
- func (cnf *Conf) LoadFile(path string) *Conf
- func (cnf *Conf) Set(key string, val interface{}) *Conf
- func (cnf *Conf) SetDefault(key string, val interface{}) *Conf
- func (cnf *Conf) SetParent(parentCnf *Conf) *Conf
- func (cnf *Conf) WriteFile() *Conf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conf ¶
type Conf struct {
// contains filtered or unexported fields
}
Conf is the configuration module.
func (*Conf) Delete ¶
Delete deletes the given key from configuration module.
The key should be a flattened path, with '.' as the delim.
func (*Conf) Get ¶
Get returns interface{} value of a given key path, or nil if key does not exist or is invalid.
If given key doesn't exist in configuration module, the chained parent data is searched for the same.
func (*Conf) GetAll ¶
GetAll merges the configured values with the default values and returns the data as a map.
func (*Conf) GetBool ¶
GetBool returns bool value of a given key path, or false if key does not exist or is invalid.
If given key doesn't exist in configuration module, the chained parent data is searched for the same.
func (*Conf) GetFloat64 ¶
GetFloat64 returns float64 value of a given key path, or 0 if key does not exist or is invalid.
If given key doesn't exist in configuration module, the chained parent data is searched for the same.
func (*Conf) GetInt ¶
GetInt returns int value of a given key path, or 0 if key does not exist or is invalid.
If given key doesn't exist in configuration module, the chained parent data is searched for the same.
func (*Conf) GetMapKeys ¶
GetMapKeys returns a string list of keys in a map addressed by the given path. If the path is not a map, an empty string slice is returned.
If given key doesn't exist in configuration module, the chained parent data is searched for the same.
func (*Conf) GetParent ¶
GetParent returns parent of conf with given name. Returns nil if no parent of given name exists.
func (*Conf) GetString ¶
GetString returns string value of a given key path, or "" if key does not exist or is invalid.
If given key doesn't exist in configuration module, the chained parent data is searched for the same.
func (*Conf) GetStrings ¶
GetStrings returns []string slice value of a given key path, or "" if key does not exist or is invalid.
If given key doesn't exist in configuration module, the chained parent data is searched for the same.
func (*Conf) LoadFile ¶
LoadFile reads and loads data from file at given path to the configuration module. Does nothing if file doesn't exist.
Ensure the file at given path is of YAML format.
func (*Conf) Set ¶
Set updates the value at given key to val.
The key should be a flattened path, with '.' as the delim.
func (*Conf) SetDefault ¶
SetDefault is like Set, but only updates the value at the given key, if the specified key does not exist.
The key should be a flattened path, with '.' as the delim.