#!/usr/bin/env bash # Static analysis gate for release builds. # # Runs go vet and staticcheck (all default checks, including U1000 for dead # code) over the whole module. A non-zero exit fails the release. # # Usage: ./scripts/check.sh # # Prefers a staticcheck binary on PATH (e.g. ~/go/bin/staticcheck) so # repeated runs are fast; falls back to `go run` with a pinned version. set -euo pipefail REPO=$(cd "$(dirname "$0")/.." && pwd) cd "$REPO" # v0.7.0 cannot read Go 1.27's export data ("export data version 4 is # greater than maximum supported version 2"); v0.8.0-rc.1 is the first # release that can. Re-pin to stable v0.8.0 once it lands. STATICCHECK_VERSION="v0.8.0-rc.1" echo "=== go vet ===" go vet ./... echo "=== staticcheck ===" if command -v staticcheck >/dev/null 2>&1; then staticcheck ./... else go run honnef.co/go/tools/cmd/staticcheck@"$STATICCHECK_VERSION" ./... fi echo "=== checks passed ==="