Open pjweinb opened 2 years ago
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.
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