mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 23:01:28 +00:00
Update yaml.go
add support for multilevel yaml config
This commit is contained in:
parent
f16688817a
commit
ba89253e4a
@ -285,9 +285,23 @@ func (c *ConfigContainer) getData(key string) (interface{}, error) {
|
|||||||
if len(key) == 0 {
|
if len(key) == 0 {
|
||||||
return nil, errors.New("key is empty")
|
return nil, errors.New("key is empty")
|
||||||
}
|
}
|
||||||
|
keys := strings.Split(key, ".")
|
||||||
|
tmpData := c.data
|
||||||
|
for _, k := range keys {
|
||||||
|
if v, ok := tmpData[k]; ok {
|
||||||
|
switch v.(type) {
|
||||||
|
|
||||||
if v, ok := c.data[key]; ok {
|
case map[string]interface{}:
|
||||||
return v, nil
|
{
|
||||||
|
tmpData = v.(map[string]interface{})
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("not exist key %q", key)
|
return nil, fmt.Errorf("not exist key %q", key)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user