Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go: Evaluate the tool directive in go1.24 for managing tool dependency #11441

Open
ialidzhikov opened this issue Feb 19, 2025 · 0 comments
Open
Labels
area/dev-productivity Developer productivity related (how to improve development) kind/enhancement Enhancement, improvement, extension

Comments

@ialidzhikov
Copy link
Member

How to categorize this issue?

/area dev-productivity
/kind enhancement

What would you like to be added:
From https://tip.golang.org/doc/go1.24#tools:

Go modules can now track executable dependencies using tool directives in go.mod. This removes the need for the previous workaround of adding tools as blank imports to a file conventionally named “tools.go”. The go tool command can now run these tools in addition to tools shipped with the Go distribution. For more information see the documentation.

With this, we could adapt all the tool dependencies we manage to the new approach:

gardener/hack/tools.go

Lines 1 to 22 in e4950e2

//go:build tools
// +build tools
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
// This package imports things required by build scripts, to force `go mod` to see them as dependencies
package tools
import (
_ "github.com/ahmetb/gen-crd-api-reference-docs"
_ "github.com/ironcore-dev/vgopath"
_ "github.com/onsi/ginkgo/v2/ginkgo"
_ "go.uber.org/mock/mockgen"
_ "golang.org/x/tools/cmd/goimports"
_ "k8s.io/code-generator"
_ "k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo"
_ "k8s.io/kube-openapi/cmd/openapi-gen"
_ "sigs.k8s.io/controller-runtime/tools/setup-envtest"
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
)

Why is this needed:
Use the idiomatic way of managing tool dependencies.

@gardener-prow gardener-prow bot added area/dev-productivity Developer productivity related (how to improve development) kind/enhancement Enhancement, improvement, extension labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dev-productivity Developer productivity related (how to improve development) kind/enhancement Enhancement, improvement, extension
Projects
None yet
Development

No branches or pull requests

1 participant