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
cmd/go: add -modversion flag setting main module version on debug.ReadBuildInfo #43535
Conversation
This PR (HEAD: 160c3da) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/281912 to see it. Tip: You can toggle comments from me using the |
Message from Go Bot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/281912. |
This PR (HEAD: 1ba020b) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/281912 to see it. Tip: You can toggle comments from me using the |
Message from Daniel Martí: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/281912. |
Message from Jay Conrod: Patch Set 2: Code-Review-1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/281912. |
Message from Luiz Ferraz: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/281912. |
Message from Daniel Martí: Patch Set 2: Code-Review-2 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/281912. |
Message from Luiz Augusto Ferraz: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/281912. |
As discussed in #29228 currently it is required very hacky workarounds to get the version of the built binary.
From my understanding the most used are variations of 'go build -ldflags="-X main.version=${version}"' and reading from the injected variable.
Currently building a binary using "go build" has a hardcoded "(devel)" version for the main module on the data for ReadBuildInfo. The program has to be installed from "go get" or "go install" in order for the version to be added.
This PR adds a "-modversion" to set the value for the main module version.