tool/gocross, pull-toolchain.sh: support a "next" Go toolchain

When TS_GO_NEXT=1 is set, update/use the
go.toolchain.next.{branch,rev} files instead.

This lets us do test deploys of Go release candidates on some
backends, without affecting all backends.

Updates tailscale/corp#36382

Change-Id: I00dbde87b219b720be5ea142325c4711f101a364
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2026-01-26 17:21:08 -08:00
committed by Brad Fitzpatrick
parent aac12ba799
commit a374cc344e
4 changed files with 32 additions and 11 deletions
+9 -3
View File
@@ -4,7 +4,7 @@
#
# gocross-wrapper.sh is a wrapper that can be aliased to 'go', which
# transparently runs the version of github.com/tailscale/go as specified repo's
# go.toolchain.rev file.
# go.toolchain.rev file (or go.toolchain.next.rev if TS_GO_NEXT=1).
#
# It also conditionally (if TS_USE_GOCROSS=1) builds gocross and uses it as a go
# wrapper to inject certain go flags.
@@ -21,6 +21,12 @@ if [[ "${OSTYPE:-}" == "cygwin" || "${OSTYPE:-}" == "msys" ]]; then
exit
fi
if [[ "${TS_GO_NEXT:-}" == "1" ]]; then
go_toolchain_rev_file="go.toolchain.next.rev"
else
go_toolchain_rev_file="go.toolchain.rev"
fi
# Locate a bootstrap toolchain and (re)build gocross if necessary. We run all of
# this in a subshell because posix shell semantics make it very easy to
# accidentally mutate the input environment that will get passed to gocross at
@@ -45,7 +51,7 @@ cd "$repo_root"
# https://github.com/tailscale/go release artifact to download.
toolchain=""
read -r REV <go.toolchain.rev
read -r REV <"$go_toolchain_rev_file"
case "$REV" in
/*)
toolchain="$REV"
@@ -148,7 +154,7 @@ unset GOROOT
# gocross is opt-in as of 2025-06-16. See tailscale/corp#26717
# and comment above in this file.
if [ "${TS_USE_GOCROSS:-}" != "1" ]; then
read -r REV <"${repo_root}/go.toolchain.rev"
read -r REV <"${repo_root}/$go_toolchain_rev_file"
case "$REV" in
/*)
toolchain="$REV"