internal/lsp/cache: fix data races to view.options

Use the concurrency-safe view.Options method.

Fixes golang/go#54214

Change-Id: If75a544ae477ee7361540c3933a18e3366d8ffd7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/420954
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dylan Le <dungtuanle@google.com>
This commit is contained in:
Robert Findley 2022-08-02 22:22:57 -04:00
Родитель 0d04f65da9
Коммит ddb90ecd31
2 изменённых файлов: 2 добавлений и 2 удалений

2
internal/lsp/cache/load.go поставляемый
Просмотреть файл

@ -141,7 +141,7 @@ func (s *snapshot) load(ctx context.Context, allowNetwork bool, scopes ...interf
} }
moduleErrs := make(map[string][]packages.Error) // module path -> errors moduleErrs := make(map[string][]packages.Error) // module path -> errors
filterer := buildFilterer(s.view.rootURI.Filename(), s.view.gomodcache, s.view.options) filterer := buildFilterer(s.view.rootURI.Filename(), s.view.gomodcache, s.view.Options())
newMetadata := make(map[PackageID]*KnownMetadata) newMetadata := make(map[PackageID]*KnownMetadata)
for _, pkg := range pkgs { for _, pkg := range pkgs {
// The Go command returns synthetic list results for module queries that // The Go command returns synthetic list results for module queries that

2
internal/lsp/cache/view.go поставляемый
Просмотреть файл

@ -392,7 +392,7 @@ func (s *snapshot) locateTemplateFiles(ctx context.Context) {
relativeTo := s.view.folder.Filename() relativeTo := s.view.folder.Filename()
searched := 0 searched := 0
filterer := buildFilterer(dir, s.view.gomodcache, s.view.options) filterer := buildFilterer(dir, s.view.gomodcache, s.view.Options())
// Change to WalkDir when we move up to 1.16 // Change to WalkDir when we move up to 1.16
err := filepath.Walk(dir, func(path string, fi os.FileInfo, err error) error { err := filepath.Walk(dir, func(path string, fi os.FileInfo, err error) error {
if err != nil { if err != nil {