From b7d29496b73463700839e8f064c1be5202017284 Mon Sep 17 00:00:00 2001 From: Matheus Alcantara Date: Fri, 18 Feb 2022 20:34:48 +0000 Subject: [PATCH] internal/lsp: don't store diagnostics for builtin.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes golang/go#44866 Change-Id: I9606df932c1b35d91816306fbcb48edc5b023b30 GitHub-Last-Rev: e6f525ed46a08ac77eac3af295c2be684405e88b GitHub-Pull-Request: golang/tools#364 Reviewed-on: https://go-review.googlesource.com/c/tools/+/386219 Trust: Robert Findley Run-TryBot: Robert Findley Trust: Hyang-Ah Hana Kim gopls-CI: kokoro Trust: Nooras Saba‎ TryBot-Result: Gopher Robot Reviewed-by: Hyang-Ah Hana Kim Reviewed-by: Robert Findley --- internal/lsp/diagnostics.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go index f4b0064024..e352e4b46b 100644 --- a/internal/lsp/diagnostics.go +++ b/internal/lsp/diagnostics.go @@ -288,7 +288,11 @@ func (s *Server) diagnosePkg(ctx context.Context, snapshot source.Snapshot, pkg return } for _, cgf := range pkg.CompiledGoFiles() { - s.storeDiagnostics(snapshot, cgf.URI, typeCheckSource, pkgDiagnostics[cgf.URI]) + // builtin.go exists only for documentation purposes, and is not valid Go code. + // Don't report distracting errors + if !snapshot.IsBuiltin(ctx, cgf.URI) { + s.storeDiagnostics(snapshot, cgf.URI, typeCheckSource, pkgDiagnostics[cgf.URI]) + } } if includeAnalysis && !pkg.HasListOrParseErrors() { reports, err := source.Analyze(ctx, snapshot, pkg, false)