From 380931b3a8f64dd4ab05195c225f80eac8418383 Mon Sep 17 00:00:00 2001 From: Steve Cliff Date: Sun, 3 May 2026 21:31:47 +0100 Subject: [PATCH] lint: align local gofumpt rules with golangci-lint v2.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumping CI to v2.5.0 surfaced two new gofumpt findings (in two test files that gofumpt v2.1.6 considered fine). Local re-format with the matching tool brings them in line. Pre-commit hook config: prepend $GOPATH/bin to PATH inside the hook entry so gofumpt + golangci-lint resolve when ~/go/bin isn't on the operator's interactive shell PATH (common — go install puts them there but PATH config varies). Without this, the hooks fail with 'Executable not found' even when the tools are installed. Pin the Makefile setup target to v2.5.0 so a fresh clone gets the same binary CI runs — keeps pre-commit and CI from drifting again. --- .pre-commit-config.yaml | 4 ++-- Makefile | 2 +- internal/server/http/p2r01_ws_test.go | 2 +- internal/server/ws/hub_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7628ed0..842b713 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: - id: gofumpt name: gofumpt description: Format Go files with gofumpt (stricter superset of gofmt) - entry: gofumpt -l -w + entry: bash -c 'PATH="$(go env GOPATH)/bin:$PATH" exec gofumpt -l -w "$@"' -- language: system types: [go] pass_filenames: true @@ -42,7 +42,7 @@ repos: - id: golangci-lint name: golangci-lint description: Run golangci-lint against the whole module (matches CI) - entry: golangci-lint run ./... + entry: bash -c 'PATH="$(go env GOPATH)/bin:$PATH" exec golangci-lint run ./...' language: system types: [go] pass_filenames: false diff --git a/Makefile b/Makefile index 9a1f472..b24798f 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ lint: ## Run golangci-lint setup: hooks ## One-time per-clone setup (Go tools + git hooks) @command -v gofumpt >/dev/null 2>&1 || go install mvdan.cc/gofumpt@latest - @command -v golangci-lint >/dev/null 2>&1 || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 + @command -v golangci-lint >/dev/null 2>&1 || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0 @echo "==> setup complete: gofumpt, golangci-lint, pre-commit hooks installed" hooks: ## Install the pre-commit hooks defined in .pre-commit-config.yaml diff --git a/internal/server/http/p2r01_ws_test.go b/internal/server/http/p2r01_ws_test.go index ed53847..bc3c57a 100644 --- a/internal/server/http/p2r01_ws_test.go +++ b/internal/server/http/p2r01_ws_test.go @@ -102,7 +102,7 @@ func enrolHostForWS(t *testing.T, srv *Server, st *store.Store, name string) (ho if err := st.SetHostCredentials(context.Background(), hostID, enc); err != nil { t.Fatalf("set creds: %v", err) } - return + return hostID, token } func sendHello(t *testing.T, c *websocket.Conn, hostname string) { diff --git a/internal/server/ws/hub_test.go b/internal/server/ws/hub_test.go index aa73a23..3753cc2 100644 --- a/internal/server/ws/hub_test.go +++ b/internal/server/ws/hub_test.go @@ -47,7 +47,7 @@ func setupTestHub(t *testing.T) (url string, token string, hostID string, st *st t.Fatalf("enroll: %v", err) } url = "ws" + strings.TrimPrefix(srv.URL, "http") + "/ws/agent" - return + return url, token, hostID, st, hub } func TestWSHelloAndHeartbeat(t *testing.T) {