This repository has been archived by the owner on Aug 21, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's Observed
Bingo returns errors when I open files in the $GOPATH/pkg/mod directory
(on Emacs with lsp-mode).
For example, textDocument/hover requests fail with the following error
message:
Root Cause
The command
go [list -f {{context.GOARCH}} {{context.Compiler}} -- unsafe
is executed byGetSizesGolist()
in golang.org/x/tools:https://github.com/golang/tools/blob/79186431cf2917562ba2e632326924b5594ce114/go/internal/packagesdriver/sizes.go#L81
The
go list
command actually fails alone if you run it on thedirectory of a non-moduled (no go.mod) dependency package.
It seems
go list
tries to creatego.md
whenGO111MODULE
is oneven if you are in
pkg/mod
. However since directories inpkg/mod
areread only, the command always fails.
I’m not sure if this behavior itself is correct (
go list
should nottry to convert packages to modules in
pkg/mod
even when MODULE ison?), but anyway it won’t work in
pkg/mod
now.This
GetSizesGoList()
is called frompackages.Load()
and it’soriginated from
*View.parse()
incache/view.go
. We currently setpath
tov.Config.Dir
, that makes thego list
command run inpath
and causes the error above.
Fix
We don’t need to set
v.Config.Dir
. The go command will be run in thecurrent working directory and that just works.