From 6330a5688ecd6814fed435d401f8ca06de570507 Mon Sep 17 00:00:00 2001 From: jessetang <1430482733@qq.com> Date: Tue, 21 Feb 2023 18:13:03 +0800 Subject: [PATCH] chore: replace deprecated method (#2667) --- contrib/log/zap/zap.go | 2 +- transport/http/codec.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/log/zap/zap.go b/contrib/log/zap/zap.go index 094e1e654..1ad8caed6 100644 --- a/contrib/log/zap/zap.go +++ b/contrib/log/zap/zap.go @@ -25,7 +25,7 @@ func (l *Logger) Log(level log.Level, keyvals ...interface{}) error { return nil } - var data []zap.Field = make([]zap.Field, 0, (keylen/2)+1) + data := make([]zap.Field, 0, (keylen/2)+1) for i := 0; i < keylen; i += 2 { data = append(data, zap.Any(fmt.Sprint(keyvals[i]), keyvals[i+1])) } diff --git a/transport/http/codec.go b/transport/http/codec.go index 156181f77..5aef7995c 100644 --- a/transport/http/codec.go +++ b/transport/http/codec.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "net/http" "net/url" @@ -67,7 +66,7 @@ func DefaultRequestDecoder(r *http.Request, v interface{}) error { data, err := io.ReadAll(r.Body) // reset body. - r.Body = ioutil.NopCloser(bytes.NewBuffer(data)) + r.Body = io.NopCloser(bytes.NewBuffer(data)) if err != nil { return errors.BadRequest("CODEC", err.Error())