Merge 41c1ee6015827757934e80733bc0976686e13f02 into d3ffc9985281dcf4d3bef604cce4e662b1a327a6

This commit is contained in:
Name 2026-03-18 15:48:29 +08:00 committed by GitHub
commit 9f37e7a3df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -389,7 +389,8 @@ func setWithProperType(val string, value reflect.Value, field reflect.StructFiel
func setIntField(val string, bitSize int, field reflect.Value) error {
if val == "" {
val = "0"
field.SetInt(0)
return nil
}
intVal, err := strconv.ParseInt(val, 10, bitSize)
if err == nil {
@ -400,7 +401,8 @@ func setIntField(val string, bitSize int, field reflect.Value) error {
func setUintField(val string, bitSize int, field reflect.Value) error {
if val == "" {
val = "0"
field.SetUint(0)
return nil
}
uintVal, err := strconv.ParseUint(val, 10, bitSize)
if err == nil {
@ -411,7 +413,8 @@ func setUintField(val string, bitSize int, field reflect.Value) error {
func setBoolField(val string, field reflect.Value) error {
if val == "" {
val = "false"
field.SetBool(false)
return nil
}
boolVal, err := strconv.ParseBool(val)
if err == nil {
@ -422,7 +425,8 @@ func setBoolField(val string, field reflect.Value) error {
func setFloatField(val string, bitSize int, field reflect.Value) error {
if val == "" {
val = "0.0"
field.SetFloat(0)
return nil
}
floatVal, err := strconv.ParseFloat(val, bitSize)
if err == nil {
@ -509,7 +513,8 @@ func setSlice(vals []string, value reflect.Value, field reflect.StructField, opt
func setTimeDuration(val string, value reflect.Value) error {
if val == "" {
val = "0"
value.Set(reflect.ValueOf(time.Duration(0)))
return nil
}
d, err := time.ParseDuration(val)