From 3a792d9c32b2634e09d90a8e377b8f77fca8f02a Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Fri, 15 Nov 2019 12:48:50 -0500 Subject: [PATCH] internal/lsp: fix panic when logging errors in snapshot.KnownPackages Fixes golang/go#35606 Change-Id: I85eef677ed2e6a971d2955ba97358d26ecf18ac1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/207346 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Michael Matloob --- internal/lsp/cache/snapshot.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go index 8e2b4d67711..575e8642d01 100644 --- a/internal/lsp/cache/snapshot.go +++ b/internal/lsp/cache/snapshot.go @@ -2,12 +2,12 @@ package cache import ( "context" - "fmt" "os" "sync" "golang.org/x/tools/go/analysis" "golang.org/x/tools/internal/lsp/source" + "golang.org/x/tools/internal/lsp/telemetry" "golang.org/x/tools/internal/span" "golang.org/x/tools/internal/telemetry/log" ) @@ -144,14 +144,14 @@ func (s *snapshot) KnownPackages(ctx context.Context) []source.Package { } cph, err := s.checkPackageHandle(ctx, pkgID, mode) if err != nil { - log.Error(ctx, fmt.Sprintf("cph.Check of %v", cph.m.pkgPath), err) + log.Error(ctx, "failed to create CheckPackageHandle", err, telemetry.Package.Of(pkgID)) continue } // Check the package now if it's not checked yet. // TODO(matloob): is this too slow? pkg, err := cph.check(ctx) if err != nil { - log.Error(ctx, fmt.Sprintf("cph.Check of %v", cph.m.pkgPath), err) + log.Error(ctx, "failed to check package", err, telemetry.Package.Of(pkgID)) continue } results = append(results, pkg)