-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/cmd/gopls: CodeAction fails with "no file information for file" #31307
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
Comments
I should probably note I see the same error if I ask for completions etc |
I'm getting this on vscode, trying gopls for the first time on a new basically empty project.
|
OK, wondering if it could be to do with where I opened up vscode - the project I opened with wasn't in the same folder as the module; closing the window and reopening in the same directory as the module seems to be the workaround. This failure mode might be unrelated to @myitcv's problem, if so apologies for the noise. |
As far as the original bug is concerned, we rely on go/packages underneath, and from the docs: // Overlays provide incomplete support for when a given file doesn't
// already exist on disk. specifically I think we do nothing at all with files that are part of a package that go list cannot yet see. |
Ah yes I'd forgotten that nuance @ianthehat. How should an editor therefore go about adding a new file? Because immediately prior to creating the file, by definition it does not exist on disk. It will then be created but quite possibly without a package clause. Then the package will be added etc... What sequence of calls/events is |
I have a similar problem on Windows. I created a go module ( |
Closing in favor of #31522 |
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?
Vim has the concept of a buffer. A buffer is the in-memory text of a file. Therefore it is possible in Vim to create a new buffer for a Go file that does not exist on disk (yet).
Consider the following
govim
testscript
in which we create a new Go buffer, populate it with some contents, then attempt to save the file. The "pre" action on saving the file is to callCodeAction
to effectively rungoimports
on the code pre-save.For every buffer in
govim
,textDocument/didOpen
is called followed bytextDocument/didChange
, so at the point of attempting to write the filegopls
will "know" exactly the contents that will be written to disk.What did you expect to see?
This to succeed.
What did you see instead?
An error returned from
gopls
:cc @stamblerre @ianthehat
The text was updated successfully, but these errors were encountered: