mirror of https://github.com/spf13/viper.git
respect durationSlice type (spf13/pflag#122)
This commit is contained in:
parent
6152d25e55
commit
21a8c83361
4
viper.go
4
viper.go
|
@ -903,7 +903,7 @@ func (v *Viper) find(lcaseKey string) interface{} {
|
||||||
return cast.ToUint(flag.ValueString())
|
return cast.ToUint(flag.ValueString())
|
||||||
case "bool":
|
case "bool":
|
||||||
return cast.ToBool(flag.ValueString())
|
return cast.ToBool(flag.ValueString())
|
||||||
case "stringSlice", "stringArray", "boolSlice", "ipSlice", "uintSlice", "intSlice":
|
case "stringSlice", "stringArray", "boolSlice", "ipSlice", "uintSlice", "intSlice", "durationSlice":
|
||||||
s := strings.TrimPrefix(flag.ValueString(), "[")
|
s := strings.TrimPrefix(flag.ValueString(), "[")
|
||||||
s = strings.TrimSuffix(s, "]")
|
s = strings.TrimSuffix(s, "]")
|
||||||
res, _ := readAsCSV(s)
|
res, _ := readAsCSV(s)
|
||||||
|
@ -974,7 +974,7 @@ func (v *Viper) find(lcaseKey string) interface{} {
|
||||||
return cast.ToUint(flag.ValueString())
|
return cast.ToUint(flag.ValueString())
|
||||||
case "bool":
|
case "bool":
|
||||||
return cast.ToBool(flag.ValueString())
|
return cast.ToBool(flag.ValueString())
|
||||||
case "stringSlice", "stringArray", "boolSlice", "ipSlice", "uintSlice", "intSlice":
|
case "stringSlice", "stringArray", "boolSlice", "ipSlice", "uintSlice", "intSlice", "durationSlice":
|
||||||
s := strings.TrimPrefix(flag.ValueString(), "[")
|
s := strings.TrimPrefix(flag.ValueString(), "[")
|
||||||
s = strings.TrimSuffix(s, "]")
|
s = strings.TrimSuffix(s, "]")
|
||||||
res, _ := readAsCSV(s)
|
res, _ := readAsCSV(s)
|
||||||
|
|
Loading…
Reference in New Issue