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:
akutz 2015-10-29 12:57:16 -05:00
parent e37b56e207
commit c25387f10d

View file

@ -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{}