From 9d0414c87c627c78e5b300b902c5a8363bc23048 Mon Sep 17 00:00:00 2001 From: Gavin Frazar Date: Fri, 13 Dec 2024 15:36:45 -0800 Subject: [PATCH] Add go-mod-tidy-all to Makefile and linter hint This will run go mod tidy in every go module directory. If the go mod diff lint fails, it will provide a hint to run this command. --- .github/workflows/lint.yaml | 2 +- Makefile | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index a75de41cae910..a746edfbf5122 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -88,7 +88,7 @@ jobs: find . -path ./e -prune -o -name go.mod -print | while read f; do echo "checking $f" pushd $(dirname "$f") > /dev/null; - go mod tidy -diff; + go mod tidy -diff || (echo "Run 'make go-mod-tidy-all' to resolve" && exit 1); popd > /dev/null; done diff --git a/Makefile b/Makefile index 3d50b08426d8e..0baf6ffbbf81f 100644 --- a/Makefile +++ b/Makefile @@ -1839,3 +1839,7 @@ create-github-release: --latest=$(LATEST) \ --verify-tag \ -F - <<< "$$NOTES" + +.PHONY: go-mod-tidy-all +go-mod-tidy-all: + find . -type "f" -name "go.mod" -execdir go mod tidy \;