From f4b4e63240932efad190fe5b1f21ed53df8a0d3d Mon Sep 17 00:00:00 2001 From: litleleprikon Date: Fri, 12 Jul 2019 21:16:29 +0200 Subject: [PATCH] internal/lsp: fix unnecessary error logging In internal/lsp/link.go appeared a bug that error message is printed even if error is not apeared. this commit is fixing this behaviour. Fixes golang/go#33087 Change-Id: I932546867d78c5c0c3d2c9dabd13287f6837f458 Reviewed-on: https://go-review.googlesource.com/c/tools/+/186037 Reviewed-by: Rebecca Stambler Run-TryBot: Rebecca Stambler --- internal/lsp/link.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/lsp/link.go b/internal/lsp/link.go index 734d3eb6..96c84705 100644 --- a/internal/lsp/link.go +++ b/internal/lsp/link.go @@ -42,7 +42,10 @@ func (s *Server) documentLink(ctx context.Context, params *protocol.DocumentLink } target = "https://godoc.org/" + target l, err := toProtocolLink(view, m, target, n.Pos(), n.End()) - view.Session().Logger().Errorf(ctx, "cannot initialize DocumentLink %s: %v", n.Path.Value, err) + if err != nil { + view.Session().Logger().Errorf(ctx, "cannot initialize DocumentLink %s: %v", n.Path.Value, err) + return false + } links = append(links, l) return false case *ast.BasicLit: