Skip to content

Commit 9660e0c

Browse files
committed
fix(install): resolve full Go version for multi-version installs
golang.org/dl uses full version names (go1.24.12) not just major.minor (go1.24). The script now: 1. Looks up the latest patch version from go.dev/dl API 2. Installs the full-versioned binary (go1.24.12) 3. Creates a symlink (go1.24 -> go1.24.12) for convenience Fixes "module does not contain package golang.org/dl/go1.24" error.
1 parent cc10228 commit 9660e0c

1 file changed

Lines changed: 37 additions & 6 deletions

File tree

scripts/install_go.sh

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,44 @@ if [ -n "$TARGET_CYCLE" ]; then
3636
exit 1
3737
fi
3838

39-
echo "Installing go${TARGET_CYCLE} via go install golang.org/dl/go${TARGET_CYCLE}@latest..."
40-
go install "golang.org/dl/go${TARGET_CYCLE}@latest" || true
39+
# golang.org/dl uses full version names (go1.24.12, not go1.24)
40+
# Look up the latest patch version for this major.minor cycle
41+
FULL_VERSION=""
42+
if [[ "$TARGET_CYCLE" =~ ^[0-9]+\.[0-9]+$ ]]; then
43+
# It's just major.minor, need to find latest patch
44+
echo "Looking up latest Go ${TARGET_CYCLE}.x version..."
45+
FULL_VERSION=$(curl -s "https://go.dev/dl/?mode=json" 2>/dev/null | \
46+
grep -oE "go${TARGET_CYCLE}\.[0-9]+" | head -1 | sed 's/go//' || true)
47+
elif [[ "$TARGET_CYCLE" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
48+
# It's already a full version
49+
FULL_VERSION="$TARGET_CYCLE"
50+
fi
51+
52+
if [ -z "$FULL_VERSION" ]; then
53+
echo "Error: Could not determine full version for Go ${TARGET_CYCLE}" >&2
54+
echo "Available versions: https://go.dev/dl/" >&2
55+
exit 1
56+
fi
4157

42-
# The go1.XX command needs to download its SDK on first run
43-
if have "go${TARGET_CYCLE}"; then
44-
echo "Downloading Go ${TARGET_CYCLE} SDK..."
45-
"go${TARGET_CYCLE}" download || true
58+
# The binary will be named go1.24.12 (full version)
59+
FULL_BINARY="go${FULL_VERSION}"
60+
61+
echo "Installing ${FULL_BINARY} via go install golang.org/dl/${FULL_BINARY}@latest..."
62+
if go install "golang.org/dl/${FULL_BINARY}@latest"; then
63+
# The go1.XX.YY command needs to download its SDK on first run
64+
if have "$FULL_BINARY"; then
65+
echo "Downloading Go ${FULL_VERSION} SDK..."
66+
"$FULL_BINARY" download || true
67+
68+
# Create symlink from go1.24 -> go1.24.12 for convenience
69+
GOBIN="$(go env GOPATH)/bin"
70+
if [ -x "$GOBIN/$FULL_BINARY" ] && [ ! -e "$GOBIN/$BINARY" ]; then
71+
ln -sf "$FULL_BINARY" "$GOBIN/$BINARY" 2>/dev/null || true
72+
echo "Created symlink: $BINARY -> $FULL_BINARY"
73+
fi
74+
fi
75+
else
76+
echo "Failed to install ${FULL_BINARY}" >&2
4677
fi
4778

4879
# Standard single-version Go installation

0 commit comments

Comments
 (0)