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

Use full go version in go.mod #140

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

bestbeforetoday
Copy link
Member

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.

@bestbeforetoday bestbeforetoday marked this pull request as ready for review June 29, 2024 12:19
@bestbeforetoday bestbeforetoday requested a review from a team as a code owner June 29, 2024 12:19
@bestbeforetoday bestbeforetoday enabled auto-merge (squash) June 29, 2024 12:19
@denyeart
Copy link
Contributor

denyeart commented Jul 1, 2024

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.

@bestbeforetoday
Copy link
Member Author

bestbeforetoday commented Jul 1, 2024

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 in go.mod does not match this syntax and there is no additional toolchain 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.

@denyeart
Copy link
Contributor

denyeart commented Jul 1, 2024

Ok thanks, I'll plan on doing the same for our other repositories.

I think my other merge created conflicts in this PR...

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.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
@bestbeforetoday bestbeforetoday merged commit eb409ab into hyperledger:main Jul 3, 2024
12 checks passed
@denyeart
Copy link
Contributor

denyeart commented Jul 3, 2024

@bestbeforetoday Next one, could you review - hyperledger/fabric-chaincode-go#112

@bestbeforetoday bestbeforetoday deleted the go-version branch July 3, 2024 16:15
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