From 69b71b7853dedc1dc42e96059aa693a4b8652062 Mon Sep 17 00:00:00 2001 From: jiacai2050 Date: Sun, 22 Mar 2020 21:30:36 +0800 Subject: [PATCH] internal/lsp: return when whyList not equal to require. Fixes golang/go#37977 --- internal/lsp/cache/mod.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/lsp/cache/mod.go b/internal/lsp/cache/mod.go index c532d89d36a..af4fd8d1c18 100644 --- a/internal/lsp/cache/mod.go +++ b/internal/lsp/cache/mod.go @@ -225,10 +225,10 @@ func goModWhy(ctx context.Context, cfg *packages.Config, folder string, data *mo return err } whyList := strings.Split(stdout.String(), "\n\n") - if len(whyList) <= 1 || len(whyList) > len(data.origParsedFile.Require) { + if len(whyList) <= 1 || len(whyList) != len(data.origParsedFile.Require) { return nil } - data.why = make(map[string]string) + data.why = make(map[string]string, len(data.origParsedFile.Require)) for i, req := range data.origParsedFile.Require { data.why[req.Mod.Path] = whyList[i] }