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

gobin: always report the main version in Package.Version #1478

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

crozzy
Copy link
Contributor

@crozzy crozzy commented Feb 12, 2025

Go 1.24 changes the way in which the main module's version is reported when the module is build via go build. What used to be just reported as (devel) will now be reported as the version + revision info (+dirty if status is uncommitted) unless the -buildvcs=false is set. All this means that the unit tests failed as the expected (devel) version wasn't found and instead "" was reported because the gobin detector doesn't set any Version if the main module's version was parseable (this isn't a big deal because the matching always works of NormalizedVersion which is always set). This change always adds the Version and the test checks the Version with the same regex ParseVersion uses.

@crozzy crozzy requested a review from a team as a code owner February 12, 2025 23:29
@crozzy crozzy requested review from vulerh and removed request for a team February 12, 2025 23:29
@crozzy
Copy link
Contributor Author

crozzy commented Feb 12, 2025

Links:

@crozzy
Copy link
Contributor Author

crozzy commented Feb 12, 2025

To be explicit, the issue is not something that will affect clair once it starts to use go1.24, it's that behaviour will change when we're detecting things built with go1.24, which is imminently. The behaviour change isn't necessarily "breaking", it just means we'll potentially match more things.

@crozzy crozzy requested review from BradLugo and RTann and removed request for vulerh February 13, 2025 15:50
@RTann RTann requested review from jvdm, daynewlee and dcaravel February 15, 2025 00:37
Copy link
Contributor

@RTann RTann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's what this is referring to:

The go build command now sets the main module’s version in the compiled binary based on the version control system tag and/or commit. A +dirty suffix will be appended if there are uncommitted changes. Use the -buildvcs=false flag to omit version control information from the binary.

https://tip.golang.org/doc/go1.24#go-command

I also see golang/go#50603 referenced in gobin/gobin.go at the very top. Can we adjust the comment based on the new changed?

@RTann
Copy link
Contributor

RTann commented Feb 15, 2025

Can you also give some examples of how this changes things? What did we see in the past and what will we now see with things built with go1.24?

@crozzy crozzy force-pushed the go1.24-main-module-reporting branch from c7ceeb6 to 8eabd0a Compare February 19, 2025 17:10
@crozzy
Copy link
Contributor Author

crozzy commented Feb 19, 2025

Can you also give some examples of how this changes things? What did we see in the past and what will we now see with things built with go1.24?

I added a new comment with an example, do you mean add a comment to the PR?

@crozzy crozzy requested a review from RTann February 19, 2025 17:14
Go 1.24 changes the way in which the main module's version is reported
when the module is build via `go build`. What used to be just reported
as `(devel)` will now be reported as the version + revision info
(+dirty if status is uncommitted) unless the -buildvcs=false is set. All
this means that the unit tests failed as the expected `(devel)` version
wasn't found and instead "" was reported because the gobin detector
doesn't set any version if the Version was parseable (this isn't a big
deal because the matching always works of NormalizedVersion which is
always set). This change always adds the Version and the test checks the
Version with the same regex `ParseVersion` uses.

Signed-off-by: crozzy <[email protected]>
@crozzy crozzy force-pushed the go1.24-main-module-reporting branch from 8eabd0a to f775696 Compare February 20, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants