Co-authored-by: zhangmj <zhangmj1@dustess.com>
This commit is contained in:
parent
9f598a31aa
commit
3dc1cd6572
@ -7,6 +7,7 @@ package binding
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"mime/multipart"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -235,6 +236,8 @@ func setWithProperType(val string, value reflect.Value, field reflect.StructFiel
|
|||||||
switch value.Interface().(type) {
|
switch value.Interface().(type) {
|
||||||
case time.Time:
|
case time.Time:
|
||||||
return setTimeField(val, field, value)
|
return setTimeField(val, field, value)
|
||||||
|
case multipart.FileHeader:
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
|
return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package binding
|
package binding
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"mime/multipart"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -43,6 +44,7 @@ func TestMappingBaseTypes(t *testing.T) {
|
|||||||
{"zero value", struct{ F uint }{}, "", uint(0)},
|
{"zero value", struct{ F uint }{}, "", uint(0)},
|
||||||
{"zero value", struct{ F bool }{}, "", false},
|
{"zero value", struct{ F bool }{}, "", false},
|
||||||
{"zero value", struct{ F float32 }{}, "", float32(0)},
|
{"zero value", struct{ F float32 }{}, "", float32(0)},
|
||||||
|
{"file value", struct{ F *multipart.FileHeader }{}, "", &multipart.FileHeader{}},
|
||||||
} {
|
} {
|
||||||
tp := reflect.TypeOf(tt.value)
|
tp := reflect.TypeOf(tt.value)
|
||||||
testName := tt.name + ":" + tp.Field(0).Type.String()
|
testName := tt.name + ":" + tp.Field(0).Type.String()
|
||||||
|
Loading…
Reference in New Issue
Block a user