set -eu

# first run go fmt
gofmt -s -w .

BINDIR="$(git rev-parse --show-toplevel)"/bin
BINARY=$BINDIR/golangci-lint
# sync with .github/workflows/lint.yml
GOLANGCI_LINT_VERSION=v2.9.0

if [ ! -f "$BINARY" ]; then
    curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b "$BINDIR" "$GOLANGCI_LINT_VERSION"
fi

$BINARY run