Support return middle level value

fix multilevel yaml config can't correct return middle level value bug
This commit is contained in:
guomao545 2018-07-27 15:33:24 +08:00 committed by GitHub
parent a09bafbf2a
commit 39fc30b8b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -290,12 +290,15 @@ func (c *ConfigContainer) getData(key string) (interface{}, error) {
keys := strings.Split(key, ".") keys := strings.Split(key, ".")
tmpData := c.data tmpData := c.data
for _, k := range keys { for idx, k := range keys {
if v, ok := tmpData[k]; ok { if v, ok := tmpData[k]; ok {
switch v.(type) { switch v.(type) {
case map[string]interface{}: case map[string]interface{}:
{ {
tmpData = v.(map[string]interface{}) tmpData = v.(map[string]interface{})
if idx == len(keys) - 1 {
return tmpData, nil
}
} }
default: default:
{ {