ci(buildbot): find go tool other than self for fallback
CACHE="$HOME/.cache/goversions"
+GO="$(which -a go | xargs -L1 realpath | grep -v "$(realpath "$0")" | head -n1)"
+if ! [[ -x "$GO" ]]; then
+ echo "ERROR: failed to find ambient go tool" >&2
+ exit 1
+fi
+
find_gomod() {
local dir="$PWD"
local f="$dir/go.mod"
@@ -34,12 +40,12 @@ find_gomod() {
if ! gomod="$(find_gomod)"; then
echo "WARNING: could not find go.mod" >&2
- exec go "$@"
+ exec "$GO" "$@"
fi
if ! version="$(grep -Po '(?<=^go\s)\d+(\.\d+)+$' "$gomod")"; then
echo "WARNING: could not find version in go.mod" >&2
- exec go "$@"
+ exec "$GO" "$@"
fi
GOROOT="${CACHE}/${version}/go"
