@@ -47,19 +47,17 @@ func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
4747 return NewHTTPError (http .StatusBadRequest , fmt .Sprintf ("Unmarshal type error: expected=%v, got=%v, field=%v, offset=%v" , ute .Type , ute .Value , ute .Field , ute .Offset ))
4848 } else if se , ok := err .(* json.SyntaxError ); ok {
4949 return NewHTTPError (http .StatusBadRequest , fmt .Sprintf ("Syntax error: offset=%v, error=%v" , se .Offset , se .Error ()))
50- } else {
51- return NewHTTPError (http .StatusBadRequest , err .Error ())
5250 }
51+ return NewHTTPError (http .StatusBadRequest , err .Error ())
5352 }
5453 case strings .HasPrefix (ctype , MIMEApplicationXML ), strings .HasPrefix (ctype , MIMETextXML ):
5554 if err = xml .NewDecoder (req .Body ).Decode (i ); err != nil {
5655 if ute , ok := err .(* xml.UnsupportedTypeError ); ok {
5756 return NewHTTPError (http .StatusBadRequest , fmt .Sprintf ("Unsupported type error: type=%v, error=%v" , ute .Type , ute .Error ()))
5857 } else if se , ok := err .(* xml.SyntaxError ); ok {
5958 return NewHTTPError (http .StatusBadRequest , fmt .Sprintf ("Syntax error: line=%v, error=%v" , se .Line , se .Error ()))
60- } else {
61- return NewHTTPError (http .StatusBadRequest , err .Error ())
6259 }
60+ return NewHTTPError (http .StatusBadRequest , err .Error ())
6361 }
6462 case strings .HasPrefix (ctype , MIMEApplicationForm ), strings .HasPrefix (ctype , MIMEMultipartForm ):
6563 params , err := c .FormParams ()
@@ -96,8 +94,7 @@ func (b *DefaultBinder) bindData(ptr interface{}, data map[string][]string, tag
9694 inputFieldName = typeField .Name
9795 // If tag is nil, we inspect if the field is a struct.
9896 if _ , ok := bindUnmarshaler (structField ); ! ok && structFieldKind == reflect .Struct {
99- err := b .bindData (structField .Addr ().Interface (), data , tag )
100- if err != nil {
97+ if err := b .bindData (structField .Addr ().Interface (), data , tag ); err != nil {
10198 return err
10299 }
103100 continue
@@ -142,10 +139,9 @@ func (b *DefaultBinder) bindData(ptr interface{}, data map[string][]string, tag
142139 }
143140 }
144141 val .Field (i ).Set (slice )
145- } else {
146- if err := setWithProperType (typeField .Type .Kind (), inputValue [0 ], structField ); err != nil {
147- return err
148- }
142+ } else if err := setWithProperType (typeField .Type .Kind (), inputValue [0 ], structField ); err != nil {
143+ return err
144+
149145 }
150146 }
151147 return nil
0 commit comments