From c74e5cc1234cc9681847c3d620c819e332bbdef1 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Mon, 16 Mar 2026 17:15:43 +0100 Subject: [PATCH] Add go fmt and go fix checks to lint Adds go-fmt and go-fix Makefile targets that fail when gofmt or go fix suggest changes. Both are wired into the lint target and used in CI. Signed-off-by: Bryan Frimin Signed-off-by: Sacha Al Himdani --- .github/workflows/make.yaml | 1 + GNUmakefile | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/make.yaml b/.github/workflows/make.yaml index bd8900695..8f5242e5c 100644 --- a/.github/workflows/make.yaml +++ b/.github/workflows/make.yaml @@ -153,6 +153,7 @@ jobs: name: "build-artifacts" - run: "chmod +x bin/probod" - run: "make generate" + - run: "make go-fmt go-fix" - name: "Run go vet" run: "go vet ./..." - name: "Run golangci-lint" diff --git a/GNUmakefile b/GNUmakefile index fadad3249..76ae689dd 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,7 +62,7 @@ endif all: build .PHONY: lint -lint: vet go-lint npm-lint +lint: vet go-fmt go-fix go-lint npm-lint .PHONY: vet vet: generate apps/console/dist/index.html apps/trust/dist/index.html @probo/emails @@ -72,6 +72,24 @@ vet: generate apps/console/dist/index.html apps/trust/dist/index.html @probo/ema npm-lint: $(NPM) run lint +.PHONY: go-fmt +go-fmt: + @output="$$(gofmt -l apps cmd packages pkg e2e)"; \ + if [ -n "$$output" ]; then \ + echo "error: 'gofmt' found unformatted files:"; \ + echo "$$output"; \ + exit 1; \ + fi + +.PHONY: go-fix +go-fix: generate apps/console/dist/index.html apps/trust/dist/index.html @probo/emails + @output="$$($(GO_BASE) fix -diff -omitzero=false ./apps/... ./cmd/... ./packages/... ./pkg/... ./e2e/...)"; \ + if [ -n "$$output" ]; then \ + echo "error: 'go fix' suggests changes; please apply them"; \ + echo "$$output"; \ + exit 1; \ + fi + .PHONY: go-lint go-lint: generate $(GOLINTCMD) run ./...