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

x/tools/go/packages: returns wrong package name when overlay has a new package name #38328

Closed
pjweinb opened this issue Apr 9, 2020 · 0 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@pjweinb
Copy link

pjweinb commented Apr 9, 2020

go version go1.14.1 darwin/amd64

Here's what happens when packages.Load is called with an overlay that has a different package name than the file on disk. (sorry about the long directory names) Line 5 shows that the file on disk is package foo, line 6 shows that the overlay for that file is package foox, and line 8 shows that Load returned package foo, not package foox.

view.go:810: packages.Load patterns=[file=/var/folders/72/mj6w6gyj5dn6yp_2_tlbdwym00052r/T/zfake439024600/foo.go]

view.go:811: config: mode:LoadMode(NeedName|NeedFiles|NeedCompiledGoFiles|NeedImports|NeedDeps|NeedTypesSizes) dir:/var/folders/72/mj6w6gyj5dn6yp_2_tlbdwym00052r/T/zfake439024600

view.go:812: Contents of dir:
view.go:826: file go.mod contains "module fake"
view.go:826: file foo.go contains "package foo\n\nimport "fmt"\n\nfunc proc() {\n\tfmt.Print("hi")\n}\n"

view.go:830: Overlay[/var/folders/72/mj6w6gyj5dn6yp_2_tlbdwym00052r/T/zfake439024600/foo.go]="package foox\n\nimport "fmt"\n\nfunc proc() {\n\tfmt.Print("hi")\n}\n"

view.go:832: cfg.BuildFlags [-modfile=/var/folders/72/mj6w6gyj5dn6yp_2_tlbdwym00052r/T/go.zfake439024600.599675223.mod]

view.go:835: Load returns pkgs: foo errors:[]

this is the cause of #32149
https://github.com/golang/go/issues/32149

@gopherbot gopherbot added this to the Unreleased milestone Apr 9, 2020
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Apr 9, 2020
@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 10, 2020
@golang golang locked and limited conversation to collaborators Apr 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants