From b6259053142f0eb51754b2acac1220a3bc200fed Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 14 Nov 2025 18:28:11 +0100 Subject: [PATCH] golangci-lint: enable gofumpt formatter And also remove old, no longer needed validate-gofmt.sh script. golangci-lint checks the formatting already for us. And add a fmt make target that just runs golangci-lint fmt for easier use. Signed-off-by: Paul Holzinger --- .golangci.yml | 5 +++++ Makefile | 5 ++++- hack/validate-gofmt.sh | 27 --------------------------- 3 files changed, 9 insertions(+), 28 deletions(-) delete mode 100755 hack/validate-gofmt.sh diff --git a/.golangci.yml b/.golangci.yml index ba1acf71..934dcf79 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,4 +1,9 @@ version: "2" + +formatters: + enable: + - gofumpt + linters: settings: staticcheck: diff --git a/Makefile b/Makefile index 8d70c2c4..31ace172 100644 --- a/Makefile +++ b/Makefile @@ -242,10 +242,13 @@ validate: # This target is only intended for development, e.g. executing it from an IDE. Use (make test) for CI or pre-release testing. test-all-local: validate-local validate-docs test-unit-local +.PHONY: fmt +fmt: tools + $(GOBIN)/golangci-lint fmt + .PHONY: validate-local validate-local: tools hack/validate-git-marks.sh - hack/validate-gofmt.sh $(GOBIN)/golangci-lint run --build-tags "${BUILDTAGS}" # An extra run with --tests=false allows detecting code unused outside of tests; # ideally the linter should be able to find this automatically. diff --git a/hack/validate-gofmt.sh b/hack/validate-gofmt.sh deleted file mode 100755 index 72757215..00000000 --- a/hack/validate-gofmt.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -IFS=$'\n' -files=( $(find . -name '*.go' | grep -v '^./vendor/' | sort || true) ) -unset IFS - -badFiles=() -for f in "${files[@]}"; do - if [ "$(gofmt -s -l < $f)" ]; then - badFiles+=( "$f" ) - fi -done - -if [ ${#badFiles[@]} -eq 0 ]; then - echo 'Congratulations! All Go source files are properly formatted.' -else - { - echo "These files are not properly gofmt'd:" - for f in "${badFiles[@]}"; do - echo " - $f" - done - echo - echo 'Please reformat the above files using "gofmt -s -w" and commit the result.' - echo - } >&2 - exit 1 -fi