ahmetb / kubectx

Faster way to switch between clusters and namespaces in kubectl
https://kubectx.dev
Apache License 2.0
17.66k stars 1.26k forks source link

Go Toolchain Version Does Not Exist #426

Closed ugrkm closed 2 months ago

ugrkm commented 2 months ago

When I try to build the project it fails. The reason is the go version is specified as '1.22' in go.mod file. When I try to build, I get:

go: downloading go1.22 (darwin/arm64)
go: download go1.22 for darwin/arm64: toolchain not available

this is as expected since there is no downloadable release for go 1.22 (because it is not a specific version). The release version should be go 1.22.0. So, we should either use 1.22.0 or specify toolchain version with:

toolchain go1.22.0

Starting with go1.21, the first release format is changed to 1.N.0. See: https://go.dev/doc/go1.21

ahmetb commented 2 months ago

toolchain directive is optional though?

ugrkm commented 2 months ago

It is optional but if it is not specified it uses go version. In this case, that version does not exist.

ahmetb commented 2 months ago

I'm still unclear. Plenty of projects do what we do at the moment and they also work fine. https://sourcegraph.com/search?q=context:global+go%5C+1.22%24+file:go.mod&patternType=regexp&sm=0

ugrkm commented 2 months ago

Some of those specify explicit go toolchain versions: https://sourcegraph.com/github.com/etcd-io/etcd/-/blob/go.mod?L5 https://sourcegraph.com/github.com/hashicorp/vault/-/blob/go.mod?L15 https://sourcegraph.com/github.com/authelia/authelia/-/blob/go.mod I think the rest specify it in different places? We don't have to specify a specific version in go.mod file. In that case, is there a script in this repo that I can run to build the project? I read the README, but couldn't find such a script. Also, thank you for the quick responses :)

ahmetb commented 2 months ago

I'm fairly sure if you have go1.22 installed on your machine, "go build" would work just fine.

ugrkm commented 2 months ago

You're right. I checked my local version. I was on go1.21.3. Since the go.mod file doesn't specify a toolchain version nor I have GOTOOLCHAIN environment variable set, go was trying to download go1.22 toolchain. Because it doesn't exist, I was getting the error I posted. I updated my go version to latest and now I can build the project since go tries to use the toolchain bundled with go version and it is greater than go1.22 (I installed go1.22.5).

I guess it is a matter of taste. A downside of not specifying a patch version is, users will have to update their go version manually when the project go version is updated.