mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 19:10:54 +00:00
Refactor ParseForm
This commit is contained in:
parent
29b1c8e1cb
commit
fe7ecc377a
24
utils.go
24
utils.go
@ -206,37 +206,19 @@ func ParseForm(form url.Values, obj interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fieldV.SetBool(b)
|
fieldV.SetBool(b)
|
||||||
case reflect.Int:
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||||
fallthrough
|
|
||||||
case reflect.Int8:
|
|
||||||
fallthrough
|
|
||||||
case reflect.Int16:
|
|
||||||
fallthrough
|
|
||||||
case reflect.Int32:
|
|
||||||
fallthrough
|
|
||||||
case reflect.Int64:
|
|
||||||
x, err := strconv.ParseInt(value, 10, 64)
|
x, err := strconv.ParseInt(value, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fieldV.SetInt(x)
|
fieldV.SetInt(x)
|
||||||
case reflect.Uint:
|
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||||
fallthrough
|
|
||||||
case reflect.Uint8:
|
|
||||||
fallthrough
|
|
||||||
case reflect.Uint16:
|
|
||||||
fallthrough
|
|
||||||
case reflect.Uint32:
|
|
||||||
fallthrough
|
|
||||||
case reflect.Uint64:
|
|
||||||
x, err := strconv.ParseUint(value, 10, 64)
|
x, err := strconv.ParseUint(value, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fieldV.SetUint(x)
|
fieldV.SetUint(x)
|
||||||
case reflect.Float32:
|
case reflect.Float32, reflect.Float64:
|
||||||
fallthrough
|
|
||||||
case reflect.Float64:
|
|
||||||
x, err := strconv.ParseFloat(value, 64)
|
x, err := strconv.ParseFloat(value, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user