From 8cd080b735b3b2bd82462845c2987d44a412ada9 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Tue, 27 Oct 2020 22:31:21 -0400 Subject: [PATCH] internal/lsp: handle nil pointer exceptions in check for Go files Fixes golang/go#42240 Change-Id: I48382613c9eb9d021a9e1dc9ca6ab6b4b1dfcf8f Reviewed-on: https://go-review.googlesource.com/c/tools/+/265763 Trust: Rebecca Stambler Run-TryBot: Rebecca Stambler gopls-CI: kokoro Reviewed-by: Robert Findley TryBot-Result: Go Bot --- internal/lsp/diagnostics.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go index cd0f408b28..d0dcb27480 100644 --- a/internal/lsp/diagnostics.go +++ b/internal/lsp/diagnostics.go @@ -460,6 +460,9 @@ func (s *Server) handleFatalErrors(ctx context.Context, snapshot source.Snapshot // If the folder has no Go code in it, we shouldn't spam the user with a warning. var hasGo bool _ = filepath.Walk(snapshot.View().Folder().Filename(), func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } if !strings.HasSuffix(info.Name(), ".go") { return nil }