#!/bin/sh
# script/fmt: format all files (writes).
#
# goimports runs with `go run` at a pinned commit, never from PATH, so
# every machine formats with the same version and nothing installs it.
set -eu

ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"

# goimports v0.42.0, 2026-08-07. Must match script/fmt-check.
GOIMPORTS_REF="golang.org/x/tools/cmd/goimports@009367f5c17a8d4c45a961a3a509277190a9a6f0"

main() {
    cd "$ROOT"
    gofmt -s -w .
    go run "$GOIMPORTS_REF" -w .
}

main "$@"
