|
@@ -141,6 +141,10 @@ func setWithProperType(val string, value reflect.Value, field reflect.StructFiel
|
|
|
case reflect.Int32:
|
|
case reflect.Int32:
|
|
|
return setIntField(val, 32, value)
|
|
return setIntField(val, 32, value)
|
|
|
case reflect.Int64:
|
|
case reflect.Int64:
|
|
|
|
|
+ switch value.Interface().(type) {
|
|
|
|
|
+ case time.Duration:
|
|
|
|
|
+ return setTimeDuration(val, value, field)
|
|
|
|
|
+ }
|
|
|
return setIntField(val, 64, value)
|
|
return setIntField(val, 64, value)
|
|
|
case reflect.Uint:
|
|
case reflect.Uint:
|
|
|
return setUintField(val, 0, value)
|
|
return setUintField(val, 0, value)
|
|
@@ -263,6 +267,15 @@ func setSlice(vals []string, value reflect.Value, field reflect.StructField) err
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func setTimeDuration(val string, value reflect.Value, field reflect.StructField) error {
|
|
|
|
|
+ d, err := time.ParseDuration(val)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return err
|
|
|
|
|
+ }
|
|
|
|
|
+ value.Set(reflect.ValueOf(d))
|
|
|
|
|
+ return nil
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func head(str, sep string) (head string, tail string) {
|
|
func head(str, sep string) (head string, tail string) {
|
|
|
idx := strings.Index(str, sep)
|
|
idx := strings.Index(str, sep)
|
|
|
if idx < 0 {
|
|
if idx < 0 {
|