#!/usr/bin/env bash
# Source this to pin Go caches inside the repo (avoids home-level permission issues).

if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
  echo "Source this script: source scripts/env.sh" >&2
  exit 1
fi

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

export GOPATH="$ROOT/tmp/go"
export GOMODCACHE="$GOPATH/pkg/mod"
export GOCACHE="$ROOT/tmp/.gocache"

mkdir -p "$ROOT/tmp/go" "$ROOT/tmp/.gocache"
