From ee138e5467e0b89040a16e431da9ec28a604a7d9 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 25 Mar 2024 13:52:53 +0100 Subject: [PATCH] chore: update dependecy, CI, and linter --- .github/workflows/pr.yml | 2 +- .golangci.yml | 22 +++++++++++++++++----- buffer/buffer_test.go | 28 ++++++++++++++-------------- buffer/retry_test.go | 6 +++--- cbreaker/cbreaker_test.go | 16 ++++++++-------- cbreaker/ratio_test.go | 2 +- connlimit/connlimit_test.go | 6 +++--- forward/example_test.go | 8 ++++---- forward/fwd_websocket_test.go | 4 ++-- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- ratelimit/tokenlimiter_test.go | 18 +++++++++--------- roundrobin/rebalancer_test.go | 3 +-- roundrobin/rr_test.go | 4 ++-- stream/stream_test.go | 16 ++++++++-------- testutils/utils.go | 4 ++-- trace/trace_test.go | 6 +++--- utils/dumpreq.go | 2 -- utils/handler_test.go | 2 +- 19 files changed, 94 insertions(+), 85 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 493cf79d..94586a88 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest env: GO_VERSION: stable - GOLANGCI_LINT_VERSION: v1.55.2 + GOLANGCI_LINT_VERSION: v1.57.1 steps: diff --git a/.golangci.yml b/.golangci.yml index f3de049c..7af70feb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,5 @@ run: - deadline: 5m - skip-files: [ ] - skip-dirs: ["internal/holsterv4"] + timeout: 5m linters-settings: govet: @@ -11,8 +9,6 @@ linters-settings: - shadow gocyclo: min-complexity: 15 - maligned: - suggest-new: true goconst: min-len: 5 min-occurrences: 3 @@ -50,6 +46,9 @@ linters-settings: settings: hugeParam: sizeThreshold: 100 + testifylint: + disable: + - go-require linters: enable-all: true @@ -92,11 +91,24 @@ linters: - nonamedreturns - gochecknoglobals # TODO(ldez) should be use on the project - nestif # TODO(ldez) should be use on the project + - musttag + - perfsprint # TODO(ldez) should be use on the project + - copyloopvar # TODO(ldez) should be use on the project (only for go>=1.22) + - intrange # TODO(ldez) should be use on the project (only for go>=1.22) + +output: + show-stats: true + sort-results: true + sort-order: + - linter + - file issues: exclude-use-default: false max-issues-per-linter: 0 max-same-issues: 0 + exclude-dirs: + - "internal/holsterv4" exclude: - 'ST1000: at least one file in a package should have a package comment' # TODO(ldez) must be fixed - 'package-comments: should have a package comment' diff --git a/buffer/buffer_test.go b/buffer/buffer_test.go index 1381fd82..51bee3be 100644 --- a/buffer/buffer_test.go +++ b/buffer/buffer_test.go @@ -19,7 +19,7 @@ import ( ) func TestSimple(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) t.Cleanup(srv.Close) @@ -87,7 +87,7 @@ func TestChunkedEncodingSuccess(t *testing.T) { } func TestChunkedEncodingLimitReached(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) t.Cleanup(srv.Close) @@ -118,7 +118,7 @@ func TestChunkedEncodingLimitReached(t *testing.T) { } func TestChunkedResponse(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { h := w.(http.Hijacker) conn, _, _ := h.Hijack() _, _ = fmt.Fprintf(conn, "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n4\r\ntest\r\n5\r\ntest1\r\n5\r\ntest2\r\n0\r\n\r\n") @@ -146,7 +146,7 @@ func TestChunkedResponse(t *testing.T) { } func TestRequestLimitReached(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) t.Cleanup(srv.Close) @@ -173,7 +173,7 @@ func TestRequestLimitReached(t *testing.T) { } func TestResponseLimitReached(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello, this response is too large")) }) t.Cleanup(srv.Close) @@ -200,7 +200,7 @@ func TestResponseLimitReached(t *testing.T) { } func TestFileStreamingResponse(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello, this response is too large to fit in memory")) }) t.Cleanup(srv.Close) @@ -228,7 +228,7 @@ func TestFileStreamingResponse(t *testing.T) { } func TestCustomErrorHandler(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello, this response is too large")) }) t.Cleanup(srv.Close) @@ -243,7 +243,7 @@ func TestCustomErrorHandler(t *testing.T) { }) // stream handler will forward requests to redirect - errHandler := utils.ErrorHandlerFunc(func(w http.ResponseWriter, req *http.Request, err error) { + errHandler := utils.ErrorHandlerFunc(func(w http.ResponseWriter, _ *http.Request, _ error) { w.WriteHeader(http.StatusTeapot) _, _ = w.Write([]byte(http.StatusText(http.StatusTeapot))) }) @@ -259,7 +259,7 @@ func TestCustomErrorHandler(t *testing.T) { } func TestNotModified(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNotModified) }) t.Cleanup(srv.Close) @@ -286,7 +286,7 @@ func TestNotModified(t *testing.T) { } func TestNoBody(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) }) t.Cleanup(srv.Close) @@ -314,7 +314,7 @@ func TestNoBody(t *testing.T) { // Make sure that stream handler preserves TLS settings. func TestPreservesTLS(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte("ok")) }) @@ -346,7 +346,7 @@ func TestPreservesTLS(t *testing.T) { } func TestNotNilBody(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) t.Cleanup(srv.Close) @@ -382,7 +382,7 @@ func TestNotNilBody(t *testing.T) { } func TestGRPCErrorResponse(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Grpc-Status", "10" /* ABORTED */) w.WriteHeader(http.StatusOK) @@ -414,7 +414,7 @@ func TestGRPCErrorResponse(t *testing.T) { } func TestGRPCOKResponse(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Grpc-Status", "0" /* OK */) _, _ = w.Write([]byte("grpc-body")) w.WriteHeader(http.StatusOK) diff --git a/buffer/retry_test.go b/buffer/retry_test.go index c54d7797..a7b62af1 100644 --- a/buffer/retry_test.go +++ b/buffer/retry_test.go @@ -13,7 +13,7 @@ import ( ) func TestSuccess(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) t.Cleanup(srv.Close) @@ -32,7 +32,7 @@ func TestSuccess(t *testing.T) { } func TestRetryOnError(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) t.Cleanup(srv.Close) @@ -52,7 +52,7 @@ func TestRetryOnError(t *testing.T) { } func TestRetryExceedAttempts(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) t.Cleanup(srv.Close) diff --git a/cbreaker/cbreaker_test.go b/cbreaker/cbreaker_test.go index fc116154..e9027387 100644 --- a/cbreaker/cbreaker_test.go +++ b/cbreaker/cbreaker_test.go @@ -19,7 +19,7 @@ import ( const triggerNetRatio = `NetworkErrorRatio() > 0.5` func TestStandbyCycle(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -36,7 +36,7 @@ func TestStandbyCycle(t *testing.T) { } func TestFullCycle(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -93,7 +93,7 @@ func TestFullCycle(t *testing.T) { } func TestRedirectWithPath(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -114,7 +114,7 @@ func TestRedirectWithPath(t *testing.T) { require.NoError(t, err) client := &http.Client{ - CheckRedirect: func(req *http.Request, via []*http.Request) error { + CheckRedirect: func(_ *http.Request, _ []*http.Request) error { return fmt.Errorf("no redirects") }, } @@ -126,7 +126,7 @@ func TestRedirectWithPath(t *testing.T) { } func TestRedirect(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -144,7 +144,7 @@ func TestRedirect(t *testing.T) { require.NoError(t, err) client := &http.Client{ - CheckRedirect: func(req *http.Request, via []*http.Request) error { + CheckRedirect: func(_ *http.Request, _ []*http.Request) error { return fmt.Errorf("no redirects") }, } @@ -156,7 +156,7 @@ func TestRedirect(t *testing.T) { } func TestTriggerDuringRecovery(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -233,7 +233,7 @@ func TestSideEffects(t *testing.T) { }) require.NoError(t, err) - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) diff --git a/cbreaker/ratio_test.go b/cbreaker/ratio_test.go index bb5e16f8..4f6834c2 100644 --- a/cbreaker/ratio_test.go +++ b/cbreaker/ratio_test.go @@ -24,7 +24,7 @@ func TestRampUp(t *testing.T) { t.Log("Ratio", ratio) t.Log("Expected", expected) t.Log("Diff", diff) - assert.EqualValues(t, 0, round(diff, 0.5, 1)) + assert.EqualValues(t, 0, round(diff, 0.5, 1)) //nolint:testifylint // the rounding is already handled. clock.Advance(clock.Millisecond) } } diff --git a/connlimit/connlimit_test.go b/connlimit/connlimit_test.go index 145ccafb..fd0e8b8d 100644 --- a/connlimit/connlimit_test.go +++ b/connlimit/connlimit_test.go @@ -62,11 +62,11 @@ func TestHitLimitAndRelease(t *testing.T) { // We've hit the limit and were able to proceed once the request has completed. func TestCustomHandlers(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) - errHandler := utils.ErrorHandlerFunc(func(w http.ResponseWriter, req *http.Request, err error) { + errHandler := utils.ErrorHandlerFunc(func(w http.ResponseWriter, _ *http.Request, _ error) { w.WriteHeader(http.StatusTeapot) _, _ = w.Write([]byte(http.StatusText(http.StatusTeapot))) }) @@ -84,7 +84,7 @@ func TestCustomHandlers(t *testing.T) { // We've hit the limit and were able to proceed once the request has completed. func TestFaultyExtract(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) diff --git a/forward/example_test.go b/forward/example_test.go index b4aafa77..f321d00f 100644 --- a/forward/example_test.go +++ b/forward/example_test.go @@ -11,7 +11,7 @@ import ( func ExampleNew_customErrHandler() { f := New(true) - f.ErrorHandler = func(w http.ResponseWriter, req *http.Request, err error) { + f.ErrorHandler = func(w http.ResponseWriter, _ *http.Request, _ error) { w.WriteHeader(http.StatusTeapot) _, _ = w.Write([]byte(http.StatusText(http.StatusTeapot))) } @@ -43,7 +43,7 @@ func ExampleNew_customErrHandler() { } func ExampleNew_responseModifier() { - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) })) defer srv.Close() @@ -75,7 +75,7 @@ func ExampleNew_responseModifier() { } func ExampleNew_customTransport() { - srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) })) defer srv.Close() @@ -113,7 +113,7 @@ func ExampleNew_customTransport() { } func ExampleNewStateListener() { - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) })) defer srv.Close() diff --git a/forward/fwd_websocket_test.go b/forward/fwd_websocket_test.go index d24596d3..1320708d 100644 --- a/forward/fwd_websocket_test.go +++ b/forward/fwd_websocket_test.go @@ -219,7 +219,7 @@ func TestWebSocketPassHost(t *testing.T) { func TestWebSocketServerWithoutCheckOrigin(t *testing.T) { f := New(true) - upgrader := gorillawebsocket.Upgrader{CheckOrigin: func(r *http.Request) bool { + upgrader := gorillawebsocket.Upgrader{CheckOrigin: func(_ *http.Request) bool { return true }} srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -412,7 +412,7 @@ func TestWebSocketUpgradeFailed(t *testing.T) { f := New(true) mux := http.NewServeMux() - mux.HandleFunc("/ws", func(w http.ResponseWriter, req *http.Request) { + mux.HandleFunc("/ws", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusBadRequest) }) diff --git a/go.mod b/go.mod index 587c7407..1d83dfb6 100644 --- a/go.mod +++ b/go.mod @@ -7,9 +7,9 @@ require ( github.com/gorilla/websocket v1.5.1 github.com/mailgun/multibuf v0.1.2 github.com/segmentio/fasthash v1.0.3 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/vulcand/predicate v1.2.0 - golang.org/x/net v0.20.0 + golang.org/x/net v0.22.0 ) require ( @@ -18,8 +18,8 @@ require ( github.com/jonboulle/clockwork v0.4.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/term v0.16.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index a378d2db..79fa24c6 100644 --- a/go.sum +++ b/go.sum @@ -51,16 +51,16 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/vulcand/predicate v1.2.0 h1:uFsW1gcnnR7R+QTID+FVcs0sSYlIGntoGOTb3rQJt50= github.com/vulcand/predicate v1.2.0/go.mod h1:VipoNYXny6c8N381zGUWkjuuNHiRbeAZhE7Qm9c+2GA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -83,8 +83,8 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -96,10 +96,10 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/ratelimit/tokenlimiter_test.go b/ratelimit/tokenlimiter_test.go index 83fd54ef..2d5583fb 100644 --- a/ratelimit/tokenlimiter_test.go +++ b/ratelimit/tokenlimiter_test.go @@ -35,7 +35,7 @@ func TestRateSetAdd(t *testing.T) { // We've hit the limit and were able to proceed on the next time run. func TestHitLimit(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -70,7 +70,7 @@ func TestHitLimit(t *testing.T) { // We've failed to extract client ip. func TestFailure(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -94,7 +94,7 @@ func TestFailure(t *testing.T) { // Make sure rates from different ips are controlled separately. func TestIsolation(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -128,7 +128,7 @@ func TestIsolation(t *testing.T) { // Make sure that expiration works (Expiration is triggered after significant amount of time passes). func TestExpiration(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -182,7 +182,7 @@ func TestExtractRates(t *testing.T) { err := rates.Add(clock.Second, 1, 1) require.NoError(t, err) - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -225,7 +225,7 @@ func TestBadRateExtractor(t *testing.T) { err := rates.Add(clock.Second, 1, 1) require.NoError(t, err) - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -264,7 +264,7 @@ func TestExtractorEmpty(t *testing.T) { err := rates.Add(clock.Second, 1, 1) require.NoError(t, err) - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -314,7 +314,7 @@ func TestInvalidParams(t *testing.T) { // We've hit the limit and were able to proceed on the next time run. func TestOptions(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) @@ -322,7 +322,7 @@ func TestOptions(t *testing.T) { err := rates.Add(clock.Second, 1, 1) require.NoError(t, err) - errHandler := utils.ErrorHandlerFunc(func(w http.ResponseWriter, req *http.Request, err error) { + errHandler := utils.ErrorHandlerFunc(func(w http.ResponseWriter, _ *http.Request, _ error) { w.WriteHeader(http.StatusTeapot) _, _ = w.Write([]byte(http.StatusText(http.StatusTeapot))) }) diff --git a/roundrobin/rebalancer_test.go b/roundrobin/rebalancer_test.go index e8e24257..1f251d9e 100644 --- a/roundrobin/rebalancer_test.go +++ b/roundrobin/rebalancer_test.go @@ -369,8 +369,7 @@ func TestRebalancerRequestRewriteListener(t *testing.T) { require.NoError(t, err) rb, err := NewRebalancer(lb, - RebalancerRequestRewriteListener(func(oldReq *http.Request, newReq *http.Request) { - })) + RebalancerRequestRewriteListener(func(_ *http.Request, _ *http.Request) {})) require.NoError(t, err) assert.NotNil(t, rb.requestRewriteListener) diff --git a/roundrobin/rr_test.go b/roundrobin/rr_test.go index a94d70f5..01b94839 100644 --- a/roundrobin/rr_test.go +++ b/roundrobin/rr_test.go @@ -34,7 +34,7 @@ func TestRemoveBadServer(t *testing.T) { } func TestCustomErrHandler(t *testing.T) { - errHandler := utils.ErrorHandlerFunc(func(w http.ResponseWriter, req *http.Request, err error) { + errHandler := utils.ErrorHandlerFunc(func(w http.ResponseWriter, _ *http.Request, _ error) { w.WriteHeader(http.StatusTeapot) _, _ = w.Write([]byte(http.StatusText(http.StatusTeapot))) }) @@ -213,7 +213,7 @@ func TestRequestRewriteListener(t *testing.T) { fwd := forward.New(false) lb, err := New(fwd, - RoundRobinRequestRewriteListener(func(oldReq *http.Request, newReq *http.Request) {})) + RoundRobinRequestRewriteListener(func(_ *http.Request, _ *http.Request) {})) require.NoError(t, err) assert.NotNil(t, lb.requestRewriteListener) diff --git a/stream/stream_test.go b/stream/stream_test.go index 7ad25de6..a9df5565 100644 --- a/stream/stream_test.go +++ b/stream/stream_test.go @@ -18,7 +18,7 @@ import ( ) func TestSimple(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) t.Cleanup(srv.Close) @@ -108,7 +108,7 @@ func TestChunkedEncodingSuccess(t *testing.T) { } func TestRequestLimitReached(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) t.Cleanup(srv.Close) @@ -135,7 +135,7 @@ func TestRequestLimitReached(t *testing.T) { } func TestResponseLimitReached(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello, this response is too large")) }) t.Cleanup(srv.Close) @@ -162,7 +162,7 @@ func TestResponseLimitReached(t *testing.T) { } func TestFileStreamingResponse(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello, this response is too large to fit in memory")) }) t.Cleanup(srv.Close) @@ -190,7 +190,7 @@ func TestFileStreamingResponse(t *testing.T) { } func TestCustomErrorHandler(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello, this response is too large")) }) t.Cleanup(srv.Close) @@ -216,7 +216,7 @@ func TestCustomErrorHandler(t *testing.T) { } func TestNotModified(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNotModified) }) t.Cleanup(srv.Close) @@ -243,7 +243,7 @@ func TestNotModified(t *testing.T) { } func TestNoBody(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) }) t.Cleanup(srv.Close) @@ -271,7 +271,7 @@ func TestNoBody(t *testing.T) { // Make sure that stream handler preserves TLS settings. func TestPreservesTLS(t *testing.T) { - srv := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) { + srv := testutils.NewHandler(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte("ok")) }) diff --git a/testutils/utils.go b/testutils/utils.go index 1e000935..53263b28 100644 --- a/testutils/utils.go +++ b/testutils/utils.go @@ -20,7 +20,7 @@ func NewHandler(handler http.HandlerFunc) *httptest.Server { // NewResponder creates a new Server with response. func NewResponder(response string) *httptest.Server { - return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(response)) })) } @@ -150,7 +150,7 @@ func MakeRequest(uri string, opts ...ReqOption) (*http.Response, []byte, error) client := &http.Client{ Transport: tr, - CheckRedirect: func(req *http.Request, via []*http.Request) error { + CheckRedirect: func(_ *http.Request, _ []*http.Request) error { return errors.New("no redirects") }, } diff --git a/trace/trace_test.go b/trace/trace_test.go index f1fd645b..8201a020 100644 --- a/trace/trace_test.go +++ b/trace/trace_test.go @@ -18,7 +18,7 @@ import ( ) func TestTraceSimple(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Length", "5") _, _ = w.Write([]byte("hello")) }) @@ -51,7 +51,7 @@ func TestTraceCaptureHeaders(t *testing.T) { "X-Re-2": []string{"2", "3"}, } - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { utils.CopyHeaders(w.Header(), respHeaders) _, _ = w.Write([]byte("hello")) }) @@ -76,7 +76,7 @@ func TestTraceCaptureHeaders(t *testing.T) { } func TestTraceTLS(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("hello")) }) diff --git a/utils/dumpreq.go b/utils/dumpreq.go index 0f5376df..11df150e 100644 --- a/utils/dumpreq.go +++ b/utils/dumpreq.go @@ -10,8 +10,6 @@ import ( ) // SerializableHTTPRequest serializable HTTP request. -// -//nolint:musttag // Cannot be changed more now. type SerializableHTTPRequest struct { Method string URL *url.URL diff --git a/utils/handler_test.go b/utils/handler_test.go index 6f960a8a..1a7b4c81 100644 --- a/utils/handler_test.go +++ b/utils/handler_test.go @@ -12,7 +12,7 @@ import ( ) func TestDefaultHandlerErrors(t *testing.T) { - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { h := w.(http.Hijacker) conn, _, _ := h.Hijack() conn.Close()