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

go/build: should not arbitrarily resolve conflicting package names #45999

Open
bcmills opened this issue May 6, 2021 · 4 comments
Open

go/build: should not arbitrarily resolve conflicting package names #45999

bcmills opened this issue May 6, 2021 · 4 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented May 6, 2021

https://play.golang.org/p/ZnGePWG7Fqs illustrates (at least) two problems with the go/build API:

  1. When ImportDir is called on a directory containing files with conflicting package declarations, the returned build.Package has its Name field set (arbitrarily!) to the first package-name seen in any of the files, and the InvalidGoFiles listed for the package include only the files with package names other than the arbitrary one. That seems wrong to me: if the package has conflicting names, it isn't up to go/build to decide which of those is “correct” — it should report all of the files as erroneous.

  2. The same file is listed twice in InvalidGoFiles.

This issue is about problem (1). (I will fix problem (2) separately, because it seems trivial.)

CC @jayconrod @matloob @rsc

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 6, 2021
@bcmills bcmills added this to the Backlog milestone May 6, 2021
@bcmills
Copy link
Contributor Author

bcmills commented May 6, 2021

(I found this while investigating #45827.)

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/317299 mentions this issue: go/build: avoid duplicates in InvalidGoFiles

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/317300 mentions this issue: cmd/go: include packages with InvalidGoFiles when filtering main packages

gopherbot pushed a commit that referenced this issue May 10, 2021
For #45827
For #39986
Updates #45999

Change-Id: I0c919b6a2e56e7003b90425487eafe0f0eadc609
Reviewed-on: https://go-review.googlesource.com/c/go/+/317299
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
@bcmills bcmills reopened this May 10, 2021
@bcmills
Copy link
Contributor Author

bcmills commented May 10, 2021

Reopening. (Gopherbot erroneously closed this due to misparsing the commit message in CL 317300; filed as #46081.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants