mirror of https://github.com/spf13/viper.git
Fixing case sensitivity bug with override values
This commit is contained in:
parent
16d5c7c27d
commit
541c1f8c59
3
viper.go
3
viper.go
|
@ -193,7 +193,6 @@ func SetDefault(key string, value interface{}) {
|
||||||
func Set(key string, value interface{}) {
|
func Set(key string, value interface{}) {
|
||||||
// If alias passed in, then set the proper override
|
// If alias passed in, then set the proper override
|
||||||
key = realKey(strings.ToLower(key))
|
key = realKey(strings.ToLower(key))
|
||||||
key = strings.ToLower(key)
|
|
||||||
override[key] = value
|
override[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,6 +391,8 @@ func Debug() {
|
||||||
pretty.Println(defaults)
|
pretty.Println(defaults)
|
||||||
fmt.Println("Override:")
|
fmt.Println("Override:")
|
||||||
pretty.Println(override)
|
pretty.Println(override)
|
||||||
|
fmt.Println("Aliases:")
|
||||||
|
pretty.Println(aliases)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Reset() {
|
func Reset() {
|
||||||
|
|
|
@ -18,6 +18,9 @@ hobbies:
|
||||||
- skateboarding
|
- skateboarding
|
||||||
- snowboarding
|
- snowboarding
|
||||||
- go
|
- go
|
||||||
|
clothing:
|
||||||
|
jacket: leather
|
||||||
|
trousers: denim
|
||||||
age: 35`)
|
age: 35`)
|
||||||
|
|
||||||
var tomlExample = []byte(`
|
var tomlExample = []byte(`
|
||||||
|
@ -62,6 +65,7 @@ func TestMarshalling(t *testing.T) {
|
||||||
assert.False(t, InConfig("state"))
|
assert.False(t, InConfig("state"))
|
||||||
assert.Equal(t, "steve", Get("name"))
|
assert.Equal(t, "steve", Get("name"))
|
||||||
assert.Equal(t, []interface{}{"skateboarding", "snowboarding", "go"}, Get("hobbies"))
|
assert.Equal(t, []interface{}{"skateboarding", "snowboarding", "go"}, Get("hobbies"))
|
||||||
|
assert.Equal(t, map[interface{}]interface{}{"jacket": "leather", "trousers": "denim"}, Get("clothing"))
|
||||||
assert.Equal(t, 35, Get("age"))
|
assert.Equal(t, 35, Get("age"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue