From c25387f10d265e6ed88fef3fe3d37bc757124983 Mon Sep 17 00:00:00 2001 From: akutz Date: Thu, 29 Oct 2015 12:57:16 -0500 Subject: [PATCH] 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. --- viper.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/viper.go b/viper.go index 20c12ec..f316671 100644 --- a/viper.go +++ b/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{}