mirror of
https://github.com/astaxie/beego.git
synced 2024-12-22 17:10:50 +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 {
|
||||
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 {
|
||||
return v, nil
|
||||
case map[string]interface{}:
|
||||
{
|
||||
tmpData = v.(map[string]interface{})
|
||||
}
|
||||
default:
|
||||
{
|
||||
return v, nil
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("not exist key %q", key)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user