From 8d5bbde9533ec5b73631cb3c6e45116cb6de4379 Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Tue, 17 Oct 2017 11:33:56 +0200 Subject: [PATCH] Fix retrieval of pflag stringArray `pflag.StringArray` suffers from the same problems as `StringSlice` did described in this issue https://github.com/spf13/viper/issues/112 --- viper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/viper.go b/viper.go index 963861ace..de1f086c3 100644 --- a/viper.go +++ b/viper.go @@ -896,7 +896,7 @@ func (v *Viper) find(lcaseKey string) interface{} { return cast.ToInt(flag.ValueString()) case "bool": return cast.ToBool(flag.ValueString()) - case "stringSlice": + case "stringSlice", "stringArray": s := strings.TrimPrefix(flag.ValueString(), "[") s = strings.TrimSuffix(s, "]") res, _ := readAsCSV(s) @@ -965,7 +965,7 @@ func (v *Viper) find(lcaseKey string) interface{} { return cast.ToInt(flag.ValueString()) case "bool": return cast.ToBool(flag.ValueString()) - case "stringSlice": + case "stringSlice", "stringArray": s := strings.TrimPrefix(flag.ValueString(), "[") s = strings.TrimSuffix(s, "]") res, _ := readAsCSV(s)