-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: vcs info not stamped when built listing .go files directly #51279
Comments
In general we stamp the VCS metadata only if the requested package is within a module in the workspace: Since CL 339170 (CC @matloob), the fake package constructed from a list of source files is not considered to be in a module, because its source files are not in general guaranteed to be scanned by Perhaps we could adjust that check to instead compare the package's directory with the directories containing the modules in the workspace. |
Not seeing the VCS metadata being populated with |
The bug is still in |
@agmt, @module17: since this issue is still open, it should not be at all surprising that it is still present. If you would like to contribute a fix, see https://go.dev/doc/contribute. |
Change https://go.dev/cl/541777 mentions this issue: |
Otherwise, VCS info are not stamped due to [1] [1] golang/go#51279
This PR adds a User-Agent header on the format `node-indexer/<hash>`. We try follow the convention described [on Wikipedia](https://en.wikipedia.org/wiki/User-Agent_header#:~:text=Mozilla/%5Bversion%5D%20(%5Bsystem%20and%20browser%20information%5D)%20%5Bplatform%5D%20(%5Bplatform%20details%5D)%20%5Bextensions%5D). This will be very useful when debugging! We inject the Git hash using option 1 from Adam's excellent resource https://developers.redhat.com/articles/2022/11/14/3-ways-embed-commit-hash-go-programs#1__using__ldflags. Option 3 doesn't work because even when building with `-buildvcs`, a `go build <file>` doesn't embed the VCS info, as tracked in this open issue: golang/go#51279 (comment) Have verified this locally using Docker build.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
N/A
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
VCS info appearing in the console :
[{-compiler gc} {CGO_ENABLED 1} {CGO_CFLAGS } {CGO_CPPFLAGS } {CGO_CXXFLAGS } {CGO_LDFLAGS } {GOARCH amd64} {GOOS windows} {GOAMD64 v1} {vcs git} {vcs.revision 2d1c081410d0f5f23fd1dd7e08794041955a2119} {vcs.time 2022-02-20T11:01:47Z} {vcs.modified false}]
What did you see instead?
[{-compiler gc} {CGO_ENABLED 1} {CGO_CFLAGS } {CGO_CPPFLAGS } {CGO_CXXFLAGS } {CGO_LDFLAGS } {GOARCH amd64} {GOOS windows} {GOAMD64 v1}]
If I run
go1.18rc1 build
instead ofgo1.18rc1 build main.go
and run the.\go-vcs-issue-repro.exe
binary, it works fine. Is it expected behavior?The text was updated successfully, but these errors were encountered: