From 215c9ce231e55e369e072d402fb9dbd0ec01aa1a Mon Sep 17 00:00:00 2001 From: Qt Date: Wed, 28 Apr 2021 18:39:09 +0800 Subject: [PATCH] use errors.New to replace fmt.Errorf will much better (#2707) --- binding/json.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binding/json.go b/binding/json.go index d62e070..45aaa49 100644 --- a/binding/json.go +++ b/binding/json.go @@ -6,7 +6,7 @@ package binding import ( "bytes" - "fmt" + "errors" "io" "net/http" @@ -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) }