This commit is contained in:
Alex Bice 2016-07-19 10:18:17 +00:00 committed by GitHub
commit a2d206d19f
2 changed files with 13 additions and 2 deletions

View file

@ -787,11 +787,13 @@ func (v *Viper) find(key string) interface{} {
if source != nil {
if reflect.TypeOf(source).Kind() == reflect.Map {
val := v.searchMap(cast.ToStringMap(source), path[1:])
if val != nil {
jww.TRACE.Println(key, "found in nested config:", val)
return val
}
}
}
}
val, exists = v.kvstore[key]
if exists {

View file

@ -883,3 +883,12 @@ func TestUnmarshalingWithAliases(t *testing.T) {
assert.Equal(t, &C, &config{Id: 1, FirstName: "Steve", Surname: "Owen"})
}
func TestShadowedNestedValue(t *testing.T) {
polyester := "polyester"
initYAML()
SetDefault("clothing.shirt", polyester)
assert.Equal(t, GetString("clothing.jacket"), "leather")
assert.Equal(t, GetString("clothing.shirt"), polyester)
}