Files
BlueArchiveToolkit/scripts/check-go-format.sh
nyaKazuha 99355effe4
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s
fix(release): 完成分发证明代际绑定与质量门禁收口
2026-09-15 21:13:52 +08:00

27 lines
607 B
Bash

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${repo_root}"
: "${GOCACHE:=/tmp/bat-go-cache}"
export GOCACHE
mapfile -t go_dirs < <(go list -f '{{.Dir}}' ./...)
go_files=()
for dir in "${go_dirs[@]}"; do
while IFS= read -r -d '' file; do
go_files+=("${file}")
done < <(find "${dir}" -maxdepth 1 -type f -name '*.go' -print0)
done
if ((${#go_files[@]} == 0)); then
exit 0
fi
formatted="$(gofmt -l "${go_files[@]}")"
if [[ -n "${formatted}" ]]; then
printf 'gofmt required; files need formatting:\n%s\n' "${formatted}" >&2
exit 1
fi