Closed bestbeforetoday closed 4 months ago
At least for core fabric, my plan was to add toolchain support if/when we needed to build with a specific version. Can you explain the benefit if we don't require building with a specific version? We should probably be consistent across all the fabric repositories so I just want to understand the rationale better before pulling the trigger.
Go 1.21 and later uses toolchains. You don't add toolchain support. If no toolchain
is specified in the go.mod
file, the version specified by the go
directive is also used as the toolchain
. Toolchain versions must be a full Go version number, not just a Go language version. Although everything still seems to work OK for me as-is, CodeQL scans generate the following warning with only a go 1.21
line and no toolchain
:
Invalid Go toolchain version As of Go 1.21, toolchain versions must use the 1.N.P syntax.
1.21
ingo.mod
does not match this syntax and there is no additionaltoolchain
directive, which may cause some go commands to fail.
The Go documentation says that the go get
command should be used to manage these go.mod
entries rather than modifying them by hand. Running go get go@1.21
right now results in these go.mod
entries:
go 1.21.11
toolchain go1.22.4
I don't want to require Go 1.21.11 and I don't want to recommend a minimum of Go 1.22.4 to build the code. Specifying either only the go
directive or both the go
and toolchain
directives as 1.21.0
seems to be the best option to comply with the current Go documentation.
Running go get go@1.21.0 toolchain@none
results in exactly the go.mod
entries in this PR.
Ok thanks, I'll plan on doing the same for our other repositories.
I think my other merge created conflicts in this PR...
@bestbeforetoday Next one, could you review - https://github.com/hyperledger/fabric-chaincode-go/pull/112
From Go 1.21, in the absence of a toolchain line in the go.mod file, the go line is used as the minimum toolchain version. Toolchain versions must be a full Go version, including patch level.