properly handle uint types

This commit is contained in:
Roman Volosatovs 2017-04-18 15:54:21 +02:00
parent 945f4d6695
commit 6152d25e55
No known key found for this signature in database
GPG Key ID: 3AC661943D80C89E
1 changed files with 6 additions and 0 deletions

View File

@ -614,6 +614,8 @@ func (v *Viper) Get(key string) interface{} {
return cast.ToString(val) return cast.ToString(val)
case int64, int32, int16, int8, int: case int64, int32, int16, int8, int:
return cast.ToInt(val) return cast.ToInt(val)
case uint64, uint32, uint16, uint8, uint:
return cast.ToUint(val)
case float64, float32: case float64, float32:
return cast.ToFloat64(val) return cast.ToFloat64(val)
case time.Time: case time.Time:
@ -897,6 +899,8 @@ func (v *Viper) find(lcaseKey string) interface{} {
switch flag.ValueType() { switch flag.ValueType() {
case "int", "int8", "int16", "int32", "int64": case "int", "int8", "int16", "int32", "int64":
return cast.ToInt(flag.ValueString()) return cast.ToInt(flag.ValueString())
case "uint", "uint8", "uint16", "uint32", "uint64":
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":
@ -966,6 +970,8 @@ func (v *Viper) find(lcaseKey string) interface{} {
switch flag.ValueType() { switch flag.ValueType() {
case "int", "int8", "int16", "int32", "int64": case "int", "int8", "int16", "int32", "int64":
return cast.ToInt(flag.ValueString()) return cast.ToInt(flag.ValueString())
case "uint", "uint8", "uint16", "uint32", "uint64":
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":