Skip to content

Make sure to build godoclint with the correct version of go#289

Merged
jhump merged 2 commits intomainfrom
jh/fix-godoclint
Mar 5, 2026
Merged

Make sure to build godoclint with the correct version of go#289
jhump merged 2 commits intomainfrom
jh/fix-godoclint

Conversation

@jhump
Copy link
Member

@jhump jhump commented Mar 5, 2026

I happened to have go1.25.1 downloaded, and newer stuff works (like modules that require 1.26) because of the automatic download and use of other toolchains.

However, when you do go install ...@<version> of a package or command that is not in the current module nor its dependencies, it does not use the toolchain indicated in go.mod. Instead, it just uses the toolchain that is actually on the path.

So this was touching a file with "go1.26" in the name, to indicate that it had downloaded and built a version ostensibly for go1.26. But it was actually being built with go1.25.1 and generating errors because it doesn't like the mismatch of Go minor versions.

The fix is to force the go install step to use a particular toolchain, which can be done using the GOTOOLCHAIN environment variable. I tried this out (after deleting the version file that a prior had had touched) and it worked to fix my issues. I also played with it a bit in this repo, to make sure it would always do the right thing after editing the version in go.mod.

@jhump jhump requested a review from stefanvanburen March 5, 2026 01:57
Copy link
Member

@stefanvanburen stefanvanburen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surprised we haven't been bitten by this before, but makes sense to me - I think we can land this, but we probably ought to port it to the other go install'd deps (at least golangci-lint and govulncheck that may be influenced by the built toolchain version)? happy to do that in a follow-up if you'd like.

@jhump
Copy link
Member Author

jhump commented Mar 5, 2026

@stefanvanburen, good call!

The golangci-lint tool doesn't use the same recipe -- I think you generally actually need a newer version of golangci-lint when upgrading to a newer Go version (vs. just building with the newer version).

But govulncheck did have the same sort of recipe, so I updated it to follow suit. In fact, that file had a better way to get the full toolchain (go env GOVERSION reports a full toolchain, even if go.mod only has a minor version / language level). So both recipes now use that method.

@stefanvanburen
Copy link
Member

thanks!

@jhump jhump merged commit 56904e3 into main Mar 5, 2026
3 checks passed
@jhump jhump deleted the jh/fix-godoclint branch March 5, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants