Skip to content

Commit

Permalink
gopls/internal/lsp/cache: request EmbedFiles from go/packages
Browse files Browse the repository at this point in the history
`Gopls` attempts to diagnose incorrect embed patterns. The logic to
do so relies on `go list` to actually resolve those patterns and to
propagate an error in case the pattern is incorrect, see also [1].

`Gopls` explicitly specifies the needed JSON fields towards
`go list -json` which internally skips evaluation steps for unneeded
fields. Currently, the embed patterns are always evaluated but there
is plans to only run pattern evaluation if needed [2].

So, explicitly ask for EmbedFiles to prepare for [2].

[1]: https://github.com/golang/tools/blob/193023cca0b707b4d668e5d332649cba285e99f7/gopls/internal/regtest/misc/embed_test.go#L26-L40
[2]: golang/go#58522
  • Loading branch information
fviernau committed Feb 22, 2023
1 parent 193023c commit 9c1addb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions gopls/internal/lsp/cache/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ func (s *snapshot) config(ctx context.Context, inv *gocommand.Invocation) *packa
packages.NeedDeps |
packages.NeedTypesSizes |
packages.NeedModule |
packages.NeedEmbedFiles |
packages.LoadMode(packagesinternal.DepsErrors) |
packages.LoadMode(packagesinternal.ForTest),
Fset: nil, // we do our own parsing
Expand Down

0 comments on commit 9c1addb

Please sign in to comment.