Skip to content

Commit

Permalink
optimize code and reduce code cyclomatic complexity (#2737)
Browse files Browse the repository at this point in the history
* optimize code and reduce code cyclomatic complexity

* optimize if-condtion

Co-authored-by: thinkerou <thinkerou@gmail.com>
  • Loading branch information
tylitianrui and thinkerou committed Jun 3, 2021
1 parent 97a32b1 commit 34ce210
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions binding/form.go
Expand Up @@ -22,10 +22,8 @@ func (formBinding) Bind(req *http.Request, obj interface{}) error {
if err := req.ParseForm(); err != nil {
return err
}
if err := req.ParseMultipartForm(defaultMemory); err != nil {
if err != http.ErrNotMultipart {
return err
}
if err := req.ParseMultipartForm(defaultMemory); err != nil && err != http.ErrNotMultipart {
return err
}
if err := mapForm(obj, req.Form); err != nil {
return err
Expand Down
6 changes: 2 additions & 4 deletions debug.go
Expand Up @@ -95,9 +95,7 @@ at initialization. ie. before any route is registered or the router is listening
}

func debugPrintError(err error) {
if err != nil {
if IsDebugging() {
fmt.Fprintf(DefaultErrorWriter, "[GIN-debug] [ERROR] %v\n", err)
}
if err != nil && IsDebugging() {
fmt.Fprintf(DefaultErrorWriter, "[GIN-debug] [ERROR] %v\n", err)
}
}

0 comments on commit 34ce210

Please sign in to comment.