31 lines
1.3 KiB
Bash
31 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Install a local Go toolchain under $OMB_STATE/go (never touches the system or
|
|
# the source tree).
|
|
set -euo pipefail
|
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/env.sh"
|
|
|
|
if [ -x "$GOROOT/bin/go" ]; then
|
|
echo "[go] already installed: $("$GOROOT/bin/go" version)"
|
|
else
|
|
mkdir -p "$OMB_STATE"
|
|
VER="$(curl -fsSL https://go.dev/VERSION?m=text 2>/dev/null | head -1 || echo go1.23.4)"
|
|
[ -z "$VER" ] && VER="go1.23.4"
|
|
TARBALL="${VER}.linux-amd64.tar.gz"
|
|
echo "[go] downloading $TARBALL"
|
|
curl -fL --retry 3 -o "$TMPDIR/$TARBALL" "https://go.dev/dl/${TARBALL}"
|
|
rm -rf "$GOROOT"
|
|
# tarball unpacks to a 'go/' dir; GOROOT is exactly $OMB_STATE/go
|
|
tar -C "$OMB_STATE" -xzf "$TMPDIR/$TARBALL"
|
|
rm -f "$TMPDIR/$TARBALL"
|
|
"$GOROOT/bin/go" version
|
|
echo "[go] done"
|
|
fi
|
|
|
|
# protoc plugins for regenerating gRPC stubs (the checked-in stubs already build;
|
|
# these are only needed if you edit a .proto and run scripts/gen_protos.sh).
|
|
if [ ! -x "$GOBIN/protoc-gen-go" ] || [ ! -x "$GOBIN/protoc-gen-go-grpc" ]; then
|
|
echo "[go] installing protoc-gen-go / protoc-gen-go-grpc"
|
|
"$GOROOT/bin/go" install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 || true
|
|
"$GOROOT/bin/go" install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.4.0 || true
|
|
fi
|