#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")"

if [ -n "${GO_BIN:-}" ]; then
  go_bin="$GO_BIN"
elif command -v go >/dev/null 2>&1; then
  go_bin="$(command -v go)"
elif [ -x /home/linuxbrew/.linuxbrew/bin/go ]; then
  go_bin=/home/linuxbrew/.linuxbrew/bin/go
else
  echo "go not found. Set GO_BIN=/path/to/go or install Go." >&2
  exit 127
fi

"$go_bin" fmt ./...
"$go_bin" vet ./...
"$go_bin" test ./... "$@"
