cmd/go: Allow go list command to accept file contents from STDIN #28809
Labels
FrozenDueToAge
GoCommand
cmd/go
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Summary
Allow
go list
to read a file from STDIN instead of the actual file on disk so that we can get information on new imports that are not yet persisted to disk.Reasoning
x/go/packages (which uses
go list
) is the basis for all new tooling (go-to-def, autocomplete, etc).When a user is editing a file on their editor by importing a new package, none of these tools can work with the new import because
go list
cannot recognize the new import statement since it is in the editor's buffer and not yet persisted back to the file on disk.The only workaround is persisting the file, which comes with its own drawbacks: every time you include a new import you have to use the package incorrectly, get a compile error, just so that you can get autocomplete and gotodef working again. Not a productive user experience. Even worse, GOPACKAGESDRIVER tools that implement caching of go list responses end up caching broken trees.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
Say I have this file:
Then I start editing it like so:
Note this file is not yet persisted to disk.
What did you expect to see?
I expect to see an autocomplete list of all of pkg/errors' public API, and if I pick one, I should be able to "GoToDef"
What did you see instead?
It doesn't work unless I persist and try again.
The text was updated successfully, but these errors were encountered: