tools: use go toolbox instead of installing a binary

Repeat of 8554d6202d.

This is a much nicer (and newer) way of handling the Go version for the
project.  The issue that caused the previous revert was that the toolbox
version was being set to 1.22.0, which is older than what some
dependencies require, specifically osbuild/images, so the 'go mod tidy'
would downgrade images to match the required toolbox version.

Setting the go and toolbox version to 1.22.6 should make it all work as
expected.

This reverts commit 7e87d1e124.

Co-authored-by: Lukáš Zapletal <lukas@zapletalovi.com>
This commit is contained in:
Achilleas Koutsou 2025-02-06 13:20:23 +01:00
parent 5cd2d8a2a9
commit 231ee2896c

View file

@ -2,20 +2,15 @@
set -eux
GO_VERSION=1.22.6
GO_BINARY=$(go env GOPATH)/bin/go$GO_VERSION
# Pin Go and toolbox versions at a reasonable version
go get go@1.22.6 toolchain@1.22.6
# 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 ./...
# Format all sources (skip vendor/):
go fmt ./cmd/... ./internal/... ./pkg/...