forked from mirror/gin
optimize code and reduce code cyclomatic complexity (#2737)
* optimize code and reduce code cyclomatic complexity * optimize if-condtion Co-authored-by: thinkerou <thinkerou@gmail.com>
This commit is contained in:
parent
97a32b1de3
commit
34ce2104ca
|
@ -22,10 +22,8 @@ func (formBinding) Bind(req *http.Request, obj interface{}) error {
|
||||||
if err := req.ParseForm(); err != nil {
|
if err := req.ParseForm(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := req.ParseMultipartForm(defaultMemory); err != nil {
|
if err := req.ParseMultipartForm(defaultMemory); err != nil && err != http.ErrNotMultipart {
|
||||||
if err != http.ErrNotMultipart {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if err := mapForm(obj, req.Form); err != nil {
|
if err := mapForm(obj, req.Form); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
6
debug.go
6
debug.go
|
@ -95,9 +95,7 @@ at initialization. ie. before any route is registered or the router is listening
|
||||||
}
|
}
|
||||||
|
|
||||||
func debugPrintError(err error) {
|
func debugPrintError(err error) {
|
||||||
if err != nil {
|
if err != nil && IsDebugging() {
|
||||||
if IsDebugging() {
|
fmt.Fprintf(DefaultErrorWriter, "[GIN-debug] [ERROR] %v\n", err)
|
||||||
fmt.Fprintf(DefaultErrorWriter, "[GIN-debug] [ERROR] %v\n", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue