mirror of
https://github.com/spf13/viper
synced 2024-11-10 15:17:02 +00:00
AllKeys() now includes bound flag and env var keys
This patch fixes a bug where the function `AllKeys()` did not include the keys for bound flags and environment variables.
This commit is contained in:
parent
e37b56e207
commit
c25387f10d
1 changed files with 12 additions and 4 deletions
16
viper.go
16
viper.go
|
@ -962,19 +962,27 @@ func (v *Viper) AllKeys() []string {
|
||||||
m := map[string]struct{}{}
|
m := map[string]struct{}{}
|
||||||
|
|
||||||
for key, _ := range v.defaults {
|
for key, _ := range v.defaults {
|
||||||
m[key] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, _ := range v.pflags {
|
||||||
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, _ := range v.env {
|
||||||
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, _ := range v.config {
|
for key, _ := range v.config {
|
||||||
m[key] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, _ := range v.kvstore {
|
for key, _ := range v.kvstore {
|
||||||
m[key] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, _ := range v.override {
|
for key, _ := range v.override {
|
||||||
m[key] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
a := []string{}
|
a := []string{}
|
||||||
|
|
Loading…
Reference in a new issue