Skip to content
Myr

fix(binding): binding error while not upload file (#3819) (#3820)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by clearcode · committed by GitHub · parent 9f598a3 · Browse files · 2 files+5 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: zhangmj <zhangmj1@dustess.com>

Diff stats

2 files+5 added−0 removed

  • other:+5 added−0 removed

2 files+5 added−0 removed

modified:binding/form_mapping_test.go+2 added
3 unmodified lines
45package binding67import (8 "mime/multipart"9 "reflect"10 "testing"11 "time"12
30 unmodified lines
43 {"zero value", struct{ F int }{}, "", int(0)},44 {"zero value", struct{ F uint }{}, "", uint(0)},45 {"zero value", struct{ F bool }{}, "", false},46 {"zero value", struct{ F float32 }{}, "", float32(0)},47 {"file value", struct{ F *multipart.FileHeader }{}, "", &multipart.FileHeader{}},48 } {49 tp := reflect.TypeOf(tt.value)50 testName := tt.name + ":" + tp.Field(0).Type.String()51
274 unmodified lines
modified:binding/form_mapping.go+3 added
5 unmodified lines
67import (8 "errors"9 "fmt"10 "mime/multipart"11 "reflect"12 "strconv"13 "strings"14 "time"
220 unmodified lines
235 case reflect.Struct:236 switch value.Interface().(type) {237 case time.Time:238 return setTimeField(val, field, value)239 case multipart.FileHeader:240 return nil241 }242 return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())243 case reflect.Map:244 return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
167 unmodified lines