Unverified Commit 3d3f2ed4 authored by astaxie's avatar astaxie Committed by GitHub

Merge pull request #3127 from kaka89/master

Refactor yaml config for support multilevel
parents a40899e6 ccaa2dd9
......@@ -285,9 +285,22 @@ func (c *ConfigContainer) getData(key string) (interface{}, error) {
if len(key) == 0 {
return nil, errors.New("key is empty")
}
if v, ok := c.data[key]; ok {
return v, nil
keys := strings.Split(key, ".")
tmpData := c.data
for _, k := range keys {
if v, ok := tmpData[k]; ok {
switch v.(type) {
case map[string]interface{}:
{
tmpData = v.(map[string]interface{})
}
default:
{
return v, nil
}
}
}
}
return nil, fmt.Errorf("not exist key %q", key)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment