Skip to content

Commit

Permalink
use errors.New to replace fmt.Errorf will much better (#2707)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2d3c authored Apr 28, 2021
1 parent c0418c4 commit 215c9ce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions binding/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package binding

import (
"bytes"
"fmt"
"errors"
"io"
"net/http"

Expand All @@ -32,7 +32,7 @@ func (jsonBinding) Name() string {

func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
if req == nil || req.Body == nil {
return fmt.Errorf("invalid request")
return errors.New("invalid request")
}
return decodeJSON(req.Body, obj)
}
Expand Down

1 comment on commit 215c9ce

@daheige
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is indeed better, I have proposed to optimize it before, it is great to see that you have modified it, instead of using fmt like gin author.

Please sign in to comment.