From 96c383b5f4c314c7d1464d2998af09796ecdfc6f Mon Sep 17 00:00:00 2001 From: Lukas Zapletal Date: Thu, 9 Jan 2025 19:46:47 +0100 Subject: [PATCH] build: use go toolbox instead installing binary --- tools/prepare-source.sh | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tools/prepare-source.sh b/tools/prepare-source.sh index 3a64ddcf22..26f9ba0730 100755 --- a/tools/prepare-source.sh +++ b/tools/prepare-source.sh @@ -2,20 +2,15 @@ set -eux -GO_VERSION=1.21.11 -GO_BINARY=$(go env GOPATH)/bin/go$GO_VERSION +# Since Go 1.21 the version is automatically maintained by the toolchain feature: +go get go@1.22 toolchain@1.22.10 -# 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 +# Update go.mod and go.sum: +go mod tidy +go mod vendor -# 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 generate ./cmd/... ./internal/... ./pkg/... -# ... and all code has been regenerated from its sources. -$GO_BINARY generate ./... - -# ... the code is formatted correctly, ... -$GO_BINARY fmt ./... +# Generate all sources (skip vendor/): +go fmt ./cmd/... ./internal/... ./pkg/...