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 >=1.21+] Log the actual toolchain to be used for a given module instead of the pre-installed toolchain #550

Open
eskultety opened this issue Jun 3, 2024 · 1 comment
Labels
bug Something isn't working gomod Pull requests/issues related to the gomod handling module

Comments

@eskultety
Copy link
Member

Currently, we report the toolchain we selected to process a project, e.g. 1.21.0 (pre-installed) but that toolchain might not end being the one to be used for the given project as the project may specify any micro release for the toolchain it desires (e.g. 1.21.8) which we're currently handling by passing GOTOOLCHAIN=auto to the underlying Go process which will first download the desired toolchain and then process the requested command (and project) with it.
We should ideally report the target toolchain that we're invoking instead of the intermediary toolchain that will just download the target one.

@eskultety
Copy link
Member Author

I worried for a moment that we'd fall into the trap of reporting the wrong toolchain due to automatic toolchain switching Go's capable of (e.g. [email protected] requires go >= 1.21.7; switching to go1.21.10), but that only happens during go build and only after go mod tidy (e.g. without running tidy: [email protected] requires go >= 1.21.7 (running go 1.21.4)). In either case, for a project dependency prefetch, all of the mentioned above is irrelevant as the toolchain declared by the main project has always has to be >= to the highest toolchain version of all of its dependencies, IOW the toolchain keyword specified by a dependency only gains meaning when building the dependency itself as the main module, but not when building it indirectly; as confirmed by docs:

Modules that are dependencies of other modules may need to set a minimum Go version requirement lower than the preferred toolchain to use when working in that module directly. In this case, the toolchain line in go.mod or go.work sets a preferred toolchain that takes precedence over the go line when the go command is deciding which toolchain to use.

@eskultety eskultety added bug Something isn't working gomod Pull requests/issues related to the gomod handling module labels Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gomod Pull requests/issues related to the gomod handling module
Projects
None yet
Development

No branches or pull requests

1 participant