From 5a4fe6a63f42d39cc0f4b0d3aaaa9983124459fc Mon Sep 17 00:00:00 2001 From: Anton Zadvorny Date: Mon, 25 Dec 2023 03:47:12 +0300 Subject: [PATCH] Fix lint errors --- app_info_test.go | 4 ++-- auth/jwt/jwt_test.go | 6 +++--- auth/token/token_test.go | 6 +++--- logger/body_util_test.go | 4 ++-- logger/logger.go | 4 ++-- logger/logger_test.go | 8 ++++---- no_cache_test.go | 4 ++-- ping_test.go | 8 ++++---- ratelimit/rate_limit_test.go | 6 +++--- real_ip_test.go | 4 ++-- recoverer/recoverer_test.go | 4 ++-- throttle/throttle_test.go | 6 +++--- timeout/timeout_test.go | 4 ++-- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/app_info_test.go b/app_info_test.go index 14f263a..34cb178 100644 --- a/app_info_test.go +++ b/app_info_test.go @@ -1,7 +1,7 @@ package middleware import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -26,7 +26,7 @@ func TestAppInfo(t *testing.T) { assert.Equal(t, "tapp", res.Header.Get("App-Name")) assert.Equal(t, "tversion", res.Header.Get("App-Version")) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) } diff --git a/auth/jwt/jwt_test.go b/auth/jwt/jwt_test.go index 088b967..38b24d8 100644 --- a/auth/jwt/jwt_test.go +++ b/auth/jwt/jwt_test.go @@ -1,7 +1,7 @@ package jwt import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -36,7 +36,7 @@ func TestJWTAuthDefaults(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusUnauthorized, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "Unauthorized\n", string(b)) @@ -49,7 +49,7 @@ func TestJWTAuthDefaults(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err = ioutil.ReadAll(res.Body) + b, err = io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) } diff --git a/auth/token/token_test.go b/auth/token/token_test.go index bf4f0a4..eeea4b8 100644 --- a/auth/token/token_test.go +++ b/auth/token/token_test.go @@ -1,7 +1,7 @@ package token import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -34,7 +34,7 @@ func TestTokenAuthDefaults(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusUnauthorized, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "Unauthorized\n", string(b)) @@ -62,7 +62,7 @@ func TestTokenAuthValidateFn(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) } diff --git a/logger/body_util_test.go b/logger/body_util_test.go index 31edf94..15d52c9 100644 --- a/logger/body_util_test.go +++ b/logger/body_util_test.go @@ -2,7 +2,7 @@ package logger import ( "errors" - "io/ioutil" + "io" "strings" "testing" @@ -39,7 +39,7 @@ func TestLoggerPeek(t *testing.T) { continue } - body, err := ioutil.ReadAll(r) + body, err := io.ReadAll(r) if !assert.NoError(t, err) { continue } diff --git a/logger/logger.go b/logger/logger.go index fb1b018..135fcaa 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -1,7 +1,7 @@ package logger import ( - "io/ioutil" + "io" "log" "net/http" "net/url" @@ -110,7 +110,7 @@ func (s *logger) body(r *http.Request) string { return "" } - r.Body = ioutil.NopCloser(rdr) + r.Body = io.NopCloser(rdr) if len(body) > 0 { body = strings.ReplaceAll(body, "\n", " ") diff --git a/logger/logger_test.go b/logger/logger_test.go index 384d0b7..ee695dc 100644 --- a/logger/logger_test.go +++ b/logger/logger_test.go @@ -2,7 +2,7 @@ package logger import ( "bytes" - "io/ioutil" + "io" "net/http" "net/http/httptest" "strings" @@ -40,7 +40,7 @@ func TestLogger(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) } @@ -57,7 +57,7 @@ func TestLoggerBody(t *testing.T) { ) handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) assert.NoError(t, err) assert.Equal(t, "12345678901234567890", string(body)) @@ -116,7 +116,7 @@ func TestLoggerSanitize(t *testing.T) { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, r.URL.Query().Get("param"), "password") - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) assert.NoError(t, err) assert.Equal(t, "body|password", string(body)) diff --git a/no_cache_test.go b/no_cache_test.go index 59c1c0c..40a13c8 100644 --- a/no_cache_test.go +++ b/no_cache_test.go @@ -1,7 +1,7 @@ package middleware import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -37,7 +37,7 @@ func TestNoCache(t *testing.T) { assert.Equal(t, "no-cache", res.Header.Get("Pragma")) assert.Equal(t, "0", res.Header.Get("X-Accel-Expires")) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) } diff --git a/ping_test.go b/ping_test.go index 66eb44f..5936b23 100644 --- a/ping_test.go +++ b/ping_test.go @@ -1,7 +1,7 @@ package middleware import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -24,7 +24,7 @@ func TestPing(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) @@ -33,7 +33,7 @@ func TestPing(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err = ioutil.ReadAll(res.Body) + b, err = io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "pong", string(b)) @@ -42,7 +42,7 @@ func TestPing(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err = ioutil.ReadAll(res.Body) + b, err = io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "pong", string(b)) } diff --git a/ratelimit/rate_limit_test.go b/ratelimit/rate_limit_test.go index a2c9618..e666768 100644 --- a/ratelimit/rate_limit_test.go +++ b/ratelimit/rate_limit_test.go @@ -1,7 +1,7 @@ package ratelimit import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "strconv" @@ -101,7 +101,7 @@ func TestRateLimitHeaders(t *testing.T) { assert.NoError(t, err) assert.InDelta(t, now.Add(time.Minute*1).Unix(), resetTS, 1) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) @@ -116,7 +116,7 @@ func TestRateLimitHeaders(t *testing.T) { assert.NoError(t, err) assert.InDelta(t, now.Add(time.Minute*1).Unix(), resetTS, 1) - b, err = ioutil.ReadAll(res.Body) + b, err = io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "Too Many Requests\n", string(b)) } diff --git a/real_ip_test.go b/real_ip_test.go index 673d1b9..4ef410f 100644 --- a/real_ip_test.go +++ b/real_ip_test.go @@ -1,7 +1,7 @@ package middleware import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "strings" @@ -35,7 +35,7 @@ func TestRealIPXRealIP(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) } diff --git a/recoverer/recoverer_test.go b/recoverer/recoverer_test.go index a6eb35a..890a3d3 100644 --- a/recoverer/recoverer_test.go +++ b/recoverer/recoverer_test.go @@ -1,7 +1,7 @@ package recoverer import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -47,7 +47,7 @@ func TestRecoverer(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) diff --git a/throttle/throttle_test.go b/throttle/throttle_test.go index 9d467c2..5b42e5a 100644 --- a/throttle/throttle_test.go +++ b/throttle/throttle_test.go @@ -1,7 +1,7 @@ package throttle import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "sync" @@ -43,7 +43,7 @@ func TestThrottleBacklog(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) }() @@ -170,7 +170,7 @@ func TestThrottleMaximum(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) }() diff --git a/timeout/timeout_test.go b/timeout/timeout_test.go index a81dfa8..53957c8 100644 --- a/timeout/timeout_test.go +++ b/timeout/timeout_test.go @@ -1,7 +1,7 @@ package timeout import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -32,7 +32,7 @@ func TestTimeoutPass(t *testing.T) { defer res.Body.Close() assert.Equal(t, http.StatusOK, res.StatusCode) - b, err := ioutil.ReadAll(res.Body) + b, err := io.ReadAll(res.Body) assert.NoError(t, err) assert.Equal(t, "resp", string(b)) }