Skip to content

Commit 0c32241

Browse files
authored
Add go toolchain support (#609)
* hack/install-go.sh: Prefer toolchain version When a toolchain directive is present in go.mod, use its version for downloading Go instead of the go directive. This directive specifies which Go version to use for building. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ram Lavi <ralavi@redhat.com> * build: Prefer toolchain version in Dockerfile When a toolchain directive is present in go.mod, use its version for downloading Go instead of the go directive. This directive specifies which Go version to use for building Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ram Lavi <ralavi@redhat.com> * vendor: Add toolchain 1.25.7, keep go 1.25 This commit sets a toolchain of 1.25.7 mant for building the project, while keeping 1.25 as the minimum go version that should be used for it. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ram Lavi <ralavi@redhat.com> --------- Signed-off-by: Ram Lavi <ralavi@redhat.com>
1 parent 03acdb4 commit 0c32241

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

build/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ WORKDIR /go/src/kubemacpool
1414
RUN dnf install -y wget && dnf clean all
1515
COPY go.mod .
1616
COPY go.sum .
17-
RUN GO_VERSION=$(sed -En 's/^go +(.*)$/\1/p' go.mod) && \
17+
RUN GO_VERSION=$(sed -En 's/^toolchain go(.*)$/\1/p' go.mod) && \
18+
if [ -z "$GO_VERSION" ]; then GO_VERSION=$(sed -En 's/^go +(.*)$/\1/p' go.mod); fi && \
1819
wget -q https://dl.google.com/go/go${GO_VERSION}.${BUILDOS}-${BUILDARCH}.tar.gz && \
1920
tar -C /usr/local -xzf go${GO_VERSION}.${BUILDOS}-${BUILDARCH}.tar.gz && \
2021
rm go${GO_VERSION}.${BUILDOS}-${BUILDARCH}.tar.gz

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module github.com/k8snetworkplumbingwg/kubemacpool
22

33
// allowed_go 1.25
4-
go 1.25.7
4+
go 1.25
5+
6+
toolchain go1.25.7
57

68
require (
79
github.com/go-logr/logr v1.4.3

hack/install-go.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/bash -xe
22

33
destination=$1
4-
version=$(grep "^go " go.mod |awk '{print $2}')
4+
version=$(sed -n 's/^toolchain go//p' go.mod)
5+
if [ -z "$version" ]; then
6+
version=$(sed -n 's/^go //p' go.mod)
7+
fi
58
arch=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
69
tarball=go$version.linux-$arch.tar.gz
710
url=https://dl.google.com/go/

0 commit comments

Comments
 (0)