From b1e4983f4982f984b4a0a5729bdcd5bd490df2f1 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Wed, 17 Dec 2025 09:26:58 +1100 Subject: [PATCH] modernize: Exclude specific packages and improve URL query string handling (#2131) * modernize: exclude specific packages and improve URL query string handling * refactor: simplify URL query string removal in websocket connection --- .github/workflows/misc.yml | 3 ++- Makefile | 3 ++- exchange/websocket/connection.go | 6 ++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/misc.yml b/.github/workflows/misc.yml index 042d7e29..ab5a744b 100644 --- a/.github/workflows/misc.yml +++ b/.github/workflows/misc.yml @@ -85,6 +85,7 @@ jobs: - name: Check Go modernise tool issues run: | - go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -test ./... + pkgs=$(go list ./... | grep -vE '/gctrpc$|/backtester/btrpc$|/database/models/') + go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -test $pkgs diff --git a/Makefile b/Makefile index 2981a259..32c98752 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,8 @@ gofumpt: modernise: @command -v modernize >/dev/null 2>&1 || go install golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest - modernize -test ./... + @pkgs=$$(go list ./... | grep -vE '/gctrpc$$|/backtester/btrpc$$|/database/models/'); \ + modernize -test $$pkgs update_deps: go mod verify diff --git a/exchange/websocket/connection.go b/exchange/websocket/connection.go index a237916b..4fbd29a9 100644 --- a/exchange/websocket/connection.go +++ b/exchange/websocket/connection.go @@ -458,10 +458,8 @@ func (c *connection) MatchReturnResponses(ctx context.Context, signature any, ex } func removeURLQueryString(u string) string { - if index := strings.Index(u, "?"); index != -1 { - return u[:index] - } - return u + baseURL, _, _ := strings.Cut(u, "?") + return baseURL } // RequireMatchWithData routes incoming data using the connection specific match system to the correct handler