-
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
runtime/debug: BuildInfo lacks information about “the main module” #33975
Comments
Given the current behavior of the However, we should also add the actual “main module”, probably as a new field in the BuildInfo struct. |
Leaning towards documentation change. "mod" line should be the version info of the module that contained the main package. I don't know what value |
Mostly it would be a clear indication that the user was not working within any version of the (For example, it might give them someplace to start sending PRs to get their users out of a known-buggy configuration.) |
If possible at this stage of modules, I would like to see the behavior improved/corrected, since there's already enough "gotchas" related to dealing with modules, it would be great to reduce those as much as possible. |
@bcmills The 'y' is arbitrary (temporary module name), and '(devel)' is arbitrary in the example. If we add any other field or repurpose the Main field and they should be meaningful, I think this should include more info than those short string. |
The |
I think I am not fully following the alternatives, but is it still under consideration to use VCS information to properly populate the version for the "main module” (not the package containing For example, from the currently open #29814:
|
Yes, but that is (mostly) orthogonal to this issue. This issue is: “should we include the main module at all if it doesn't contribute any packages to the build, and if so, where?” #29814 is, “if the main module appears in |
BuildInfo.Main is the module with the main package, not the main module (where those differ). |
Change https://golang.org/cl/196522 mentions this issue: |
I thought the module with the main package was the main module. |
@icholy The term "main module" is described in the first sentence at https://golang.org/cmd/go/#hdr-The_main_module_and_the_build_list. |
@dmitris sorry for being dense, but how would it possible for the main module to be different from the module with the main package? |
@icholy Consider the commands below:
The main module is The main package is |
The term "main module" has a special meaning [1] and is not what we intended to refer to with BuildInfo.Main. [1] https://golang.org/cmd/go/#hdr-The_main_module_and_the_build_list Updates #33975 Change-Id: Ieaba5fcacee2e87c5c15fa7425527bbd64ada5d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/196522 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
I think we shouldn't and that the current behavior is good as is. From a reproducibility point of view, the module of the main package and its dependencies should be everything that define the build, and given the same versions (and build flags, and GOOS/GOARCH, etc), the binary should build the same regardless of what module it's built from. |
@FiloSottile, I think the main use-case for embedding info about “the main module” is specifically for controlling test behavior. If a given test is in the main module (or in another module with the same maintainers) then it seems more reasonable for that test to assume or require properties of the development environment above and beyond the basic |
Given #37475 this might not actually be necessary — the VCS stamp will be present if the binary is in the main module, and will not be present otherwise. |
279: Feature/Analytics r=alallema a=brunoocasali - Add `User-Agent` inside the pre-defined headers Add Go support as requested here meilisearch/integration-guides#150 I tried other options, but they do not fit so well: - https://pkg.go.dev/debug/buildinfo (does not work very well :/ has a lot of issues golang/go#29814, golang/go#33975 - https://github.com/ahmetb/govvv (I think it is not an option since it seems to be not maintained anymore). Co-authored-by: Bruno Casali <brunoocasali@gmail.com> Co-authored-by: Amélie <alallema@users.noreply.github.com>
279: Feature/Analytics r=alallema a=brunoocasali - Add `User-Agent` inside the pre-defined headers Add Go support as requested here meilisearch/integration-guides#150 I tried other options, but they do not fit so well: - https://pkg.go.dev/debug/buildinfo (does not work very well :/ has a lot of issues golang/go#29814, golang/go#33975 - https://github.com/ahmetb/govvv (I think it is not an option since it seems to be not maintained anymore). Co-authored-by: Bruno Casali <brunoocasali@gmail.com> Co-authored-by: Amélie <alallema@users.noreply.github.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
From within module
y
, build a binary from modulex
than examines theMain
field ofruntime/debug.BuildInfo
:https://go-review.googlesource.com/c/go/+/192558/1/src/cmd/go/testdata/script/mod_modinfo.txt
What did you expect to see?
Since the field's documentation says it is (emphasis mine) “The main module information”, I expect it to contain information about “the main module” in the sense of https://tip.golang.org/cmd/go/#hdr-The_main_module_and_the_build_list.
For this example, I expected the information reported by the binary to look like
What did you see instead?
Instead, the
Main
field contains information about the module containing packagemain
:with no information about the main module (
y
) at all, not even as adep
.As far as I can tell, it has been that way since module support was first implemented.
CC @jayconrod @rsc @thepudds @hyangah
The text was updated successfully, but these errors were encountered: