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/gopls: weird files treated as packages #54815

Open
pjweinb opened this issue Sep 1, 2022 · 1 comment
Open

x/tools/gopls: weird files treated as packages #54815

pjweinb opened this issue Sep 1, 2022 · 1 comment
Labels
gopls Issues related to the Go language server, gopls. 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 Sep 1, 2022

If one edits a random text file, say /tmp/foof, go/packages/golist.go treats it as a Go file. The comment at line 349 is
"// If we get nothing back from go list,
// try to make this file into its own ad-hoc package.
// TODO(rstambler): Should this check against the original response?"

One would think it should look to see if there is a .go file involved somehow. Otherwise the gopls output is polluted by a lot of messages like

[Error - 10:22:27 AM] 2022/09/01 10:22:27 analyzer "tests" failed: analysis tests for package /tmp/foof panicked: runtime error: invalid memory address or nil pointer dereference

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Sep 1, 2022
@gopherbot gopherbot added this to the Unreleased milestone Sep 1, 2022
@jamalc jamalc modified the milestones: Unreleased, gopls/later Sep 1, 2022
@adonovan adonovan added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 8, 2022
@adonovan
Copy link
Member

Do you remember anything about how this happened? Typical LSP clients like VS Code and Emacs+eglot won't consider an arbitrary text file as a Go file unless it has a .go suffix, so gopls isn't involved. Did you force the interpretation to Go using the menu at the lower right of VS Code? I tried this, and gopls became usable within the Go file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. 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

4 participants