From b67bc8f00502b1f555b9db64cd2dfc03098cfc8f Mon Sep 17 00:00:00 2001 From: guonaihong Date: Sat, 29 Jun 2019 20:43:32 +0800 Subject: [PATCH] Gin1.5 bytes.Buffer to strings.Builder (#1939) * Replace bytes.Buffer to strings.Builder * Merge the latest changes * Update errors.go --- debug.go | 3 +-- errors.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/debug.go b/debug.go index 64777c2..49080db 100644 --- a/debug.go +++ b/debug.go @@ -5,7 +5,6 @@ package gin import ( - "bytes" "fmt" "html/template" "runtime" @@ -38,7 +37,7 @@ func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) { func debugPrintLoadTemplate(tmpl *template.Template) { if IsDebugging() { - var buf bytes.Buffer + var buf strings.Builder for _, tmpl := range tmpl.Templates() { buf.WriteString("\t- ") buf.WriteString(tmpl.Name()) diff --git a/errors.go b/errors.go index 6070ff5..25e8ff6 100644 --- a/errors.go +++ b/errors.go @@ -5,9 +5,9 @@ package gin import ( - "bytes" "fmt" "reflect" + "strings" "github.com/gin-gonic/gin/internal/json" ) @@ -158,7 +158,7 @@ func (a errorMsgs) String() string { if len(a) == 0 { return "" } - var buffer bytes.Buffer + var buffer strings.Builder for i, msg := range a { fmt.Fprintf(&buffer, "Error #%02d: %s\n", i+1, msg.Err) if msg.Meta != nil {