Closed ugrkm closed 2 months ago
toolchain directive is optional though?
It is optional but if it is not specified it uses go version. In this case, that version does not exist.
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
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 :)
I'm fairly sure if you have go1.22 installed on your machine, "go build" would work just fine.
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.
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:
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:
Starting with go1.21, the first release format is changed to 1.N.0. See: https://go.dev/doc/go1.21