From 0c266f9c7206e266f55159f1775f814ea38e8c9a Mon Sep 17 00:00:00 2001 From: 0x2d3c Date: Tue, 27 Apr 2021 22:30:10 +0800 Subject: [PATCH] use errors.New to replace fmt.Errorf will much better --- binding/json.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binding/json.go b/binding/json.go index d62e070594..45aaa49487 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) }