-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat(go): fix parsing main module version for go >= 1.24 #8433
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
Conversation
This commit refines the logic for determining the main module version in projects using Go version 1.24 and later. The changes ensure that a more accurate version is used by leveraging the `ldflags` version when appropriate. Key adjustments include: - Checking for a version retrieved from `go buildinfo`. - Prioritizing the `ldflags` version when the retrieved version is a placeholder version like "v0.0.0" and a valid `ldflags` version exists. - Defaulting to the `ldflags` version if no version is found in the build information. These improvements enhance the reliability of version handling in builds. Signed-off-by: maksim.nabokikh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. LGTM.
I left a small comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For several reasons, I propose that we stop including binaries as test data in the future. First, having binaries in the repository will bloat its size, which makes operations like cloning slower. Additionally, since Git cannot diff binary files, each commit significantly increases the repository’s size. Moreover, because we don’t know how these binaries were generated, it’s difficult to modify them if needed.
We do have an idea to automatically generate these binaries (using go generate
, for example) when running unit tests. Could you please remove the binaries for now and comment out the tests? Once this PR is merged, we’ll generate the necessary test binaries on our end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sure
Co-authored-by: DmitriyLewen <[email protected]>
Signed-off-by: maksim.nabokikh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
…y#8433) Signed-off-by: maksim.nabokikh <[email protected]> Co-authored-by: DmitriyLewen <[email protected]>
…y#8433) Signed-off-by: maksim.nabokikh <[email protected]> Co-authored-by: DmitriyLewen <[email protected]>
…y#8433) Signed-off-by: maksim.nabokikh <[email protected]> Co-authored-by: DmitriyLewen <[email protected]>
Description
This commit refines the logic for determining the main module version in projects using Go version 1.24 and later. The changes ensure that a more accurate version is used by leveraging the
ldflags
version when appropriate.Key adjustments include:
go buildinfo
.ldflags
version when the retrieved version is a placeholder version like "v0.0.0" and a validldflags
version exists.ldflags
version if no version is found in the build information.These improvements enhance the reliability of version handling in builds.
Related issues
Related PRs
Checklist