mirror of
https://github.com/spf13/viper
synced 2024-12-22 11:37: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{}{}
|
||||
|
||||
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 {
|
||||
m[key] = struct{}{}
|
||||
m[strings.ToLower(key)] = struct{}{}
|
||||
}
|
||||
|
||||
for key, _ := range v.kvstore {
|
||||
m[key] = struct{}{}
|
||||
m[strings.ToLower(key)] = struct{}{}
|
||||
}
|
||||
|
||||
for key, _ := range v.override {
|
||||
m[key] = struct{}{}
|
||||
m[strings.ToLower(key)] = struct{}{}
|
||||
}
|
||||
|
||||
a := []string{}
|
||||
|
|
Loading…
Reference in a new issue