From 8f0549b29019a498db0efdcb1ccb0dac80bebfa0 Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 16 Jun 2026 13:35:46 +0200 Subject: [PATCH] feat: add fix-all script for recursive go fix --- justfile | 3 +++ scripts/fix-all.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 scripts/fix-all.sh diff --git a/justfile b/justfile index e3ffd9a..cb5a074 100644 --- a/justfile +++ b/justfile @@ -53,3 +53,6 @@ new-data-fix name: run-fixes: go run ./cmd/user run-fixes + +fix-all: + bash scripts/fix-all.sh diff --git a/scripts/fix-all.sh b/scripts/fix-all.sh new file mode 100755 index 0000000..00cc2bb --- /dev/null +++ b/scripts/fix-all.sh @@ -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" \ No newline at end of file