feat: add fix-all script for recursive go fix

This commit is contained in:
2026-06-16 13:35:46 +02:00
committed by Milas Holsting
parent a83377671e
commit 8f0549b290
2 changed files with 32 additions and 0 deletions

View File

@@ -53,3 +53,6 @@ new-data-fix name:
run-fixes:
go run ./cmd/user run-fixes
fix-all:
bash scripts/fix-all.sh

29
scripts/fix-all.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
get_hash() {
find . -name "*.go" -type f ! -path "./vendor/*" -exec sha256sum {} + | sha256sum | cut -d' ' -f1
}
echo "running go fix recursively until no changes..."
prev_hash=$(get_hash)
iteration=0
while true; do
iteration=$((iteration + 1))
echo "iteration $iteration..."
go fix ./... >/dev/null 2>&1 || true
curr_hash=$(get_hash)
if [[ "$prev_hash" == "$curr_hash" ]]; then
echo "no more changes after $iteration iteration(s)"
break
fi
prev_hash=$curr_hash
done
echo "done"