Beispiel #1
0
func (l TestLoader) LoadKeyValue() mcore.StringKeyValueMap {
	c := mcore.NewStringKeyValueMap()
	c.Put("a", "a")
	c.Put("b", "0")
	c.Put("c", "5")
	return c
}
Beispiel #2
0
func (c *AppConf) Load() *AppConf {
	if c.IsExist() {
		logger.Tracef("Load config. AppName:%s Location:%s", c.AppName, c.Location())
		c.StringKeyValueMap = ini.NewIniConfig(c.Location()).LoadKeyValue()
		return c
	}
	logger.Tracef("Location not exists, Create Default StringKeyValueMap. AppName:%s", c.AppName)
	c.StringKeyValueMap = mcore.NewStringKeyValueMap()
	c.performLoad = false
	return c
}
Beispiel #3
0
func (c IniConfig) LoadKeyValue() mcore.StringKeyValueMap {
	logger.Debugf("load config from %v.", c.Locations)
	skv := mcore.NewStringKeyValueMap()
	for _, section := range c.Sections() {
		options, _ := c.Config.Options(section)
		for _, option := range options {
			k := ""
			if section == "DEFAULT" {
				k = fmt.Sprintf("%s", option)
			} else {
				k = fmt.Sprintf("%s@%s", option, section)
			}
			v, _ := c.Config.String(section, option)
			logger.Tracef("load key:%s value:%s", k, v)
			skv.Put(k, v)
		}
	}
	return skv
}