From e7c9de23ff8a43a51b4a9f96006b6e4b4b3cd1d1 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 21 Jan 2022 15:44:05 -0500 Subject: [PATCH] internal/lsp/cache: remove unsynchronized write to snapshot.files snapshot.GetVersionedFile already memoizes the file handle in snapshot.files. There is no reason to do another write, and this write is unsynchronized. Fixes golang/go#50747 Change-Id: Ib196395135de6f22dd59169accb756665ad10e58 Reviewed-on: https://go-review.googlesource.com/c/tools/+/380214 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Bryan Mills gopls-CI: kokoro TryBot-Result: Gopher Robot --- internal/lsp/cache/view.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index e16422eed8..eb61d570d8 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -396,11 +396,10 @@ func (s *snapshot) locateTemplateFiles(ctx context.Context) { excluded := pathExcludedByFilter(relpath, dir, s.view.gomodcache, s.view.options) if fileHasExtension(path, suffixes) && !excluded && !fi.IsDir() { k := span.URIFromPath(path) - fh, err := s.GetVersionedFile(ctx, k) + _, err := s.GetVersionedFile(ctx, k) if err != nil { return nil } - s.files[k] = fh } searched++ if fileLimit > 0 && searched > fileLimit {