From 7e87d1e124c1bbd49f7a0afcd732fd83357f4e57 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Thu, 6 Feb 2025 11:23:44 +0100 Subject: [PATCH] tools: revert prepare-source.sh to use downloaded go binary The new script can cause changes to the go.mod when executing `go get go@version`, downgrading packages that we want to bump, which can revert changes we want the tool to be tidying. We can work around this for now, but with the script being part of our PR checks, we also need to revert the script so we can get module updates through. This reverts 8554d6202dff0f887d0f8bec838f15c24af02e8d --- tools/prepare-source.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/prepare-source.sh b/tools/prepare-source.sh index 3c0fe7c5d..300fabf53 100755 --- a/tools/prepare-source.sh +++ b/tools/prepare-source.sh @@ -2,15 +2,20 @@ set -eux -# Pin Go and toolbox versions at a reasonable version -go get go@1.22.0 toolchain@1.22.0 +GO_VERSION=1.22.6 +GO_BINARY=$(go env GOPATH)/bin/go$GO_VERSION -# Update go.mod and go.sum: -go mod tidy -go mod vendor +# this is the official way to get a different version of golang +# see https://go.dev/doc/manage-install +go install golang.org/dl/go$GO_VERSION@latest +$GO_BINARY download -# Generate all sources (skip vendor/): -go generate ./cmd/... ./internal/... ./pkg/... +# ensure that go.mod and go.sum are up to date, ... +$GO_BINARY mod tidy +$GO_BINARY mod vendor -# Generate all sources (skip vendor/): -go fmt ./cmd/... ./internal/... ./pkg/... +# ... and all code has been regenerated from its sources. +$GO_BINARY generate ./... + +# ... the code is formatted correctly, ... +$GO_BINARY fmt ./...