From dd2bc6543e01a68a533652d3c37e66055b5b3c70 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 1 Jan 2025 23:15:35 -0500 Subject: [PATCH] x/tools: remove dead code These unused functions and methods were discovered by a (work in progress) dead function analyzer. Change-Id: Iaa9c5fd4f06bdcd5d7c6e194bcc24d6b37df8f4c Reviewed-on: https://go-review.googlesource.com/c/tools/+/639675 Auto-Submit: Alan Donovan Reviewed-by: Robert Findley LUCI-TryBot-Result: Go LUCI --- internal/jsonrpc2/jsonrpc2.go | 9 --------- internal/jsonrpc2/serve_go116.go | 5 ----- internal/jsonrpc2/serve_pre116.go | 14 -------------- 3 files changed, 28 deletions(-) diff --git a/internal/jsonrpc2/jsonrpc2.go b/internal/jsonrpc2/jsonrpc2.go index aed5823..a17d6df 100644 --- a/internal/jsonrpc2/jsonrpc2.go +++ b/internal/jsonrpc2/jsonrpc2.go @@ -112,15 +112,6 @@ func (a *async) done() { close(a.ready) } -func (a *async) isDone() bool { - select { - case <-a.ready: - return true - default: - return false - } -} - func (a *async) wait() error { <-a.ready err := <-a.firstErr diff --git a/internal/jsonrpc2/serve_go116.go b/internal/jsonrpc2/serve_go116.go index 46e442a..595e525 100644 --- a/internal/jsonrpc2/serve_go116.go +++ b/internal/jsonrpc2/serve_go116.go @@ -8,12 +8,7 @@ package jsonrpc2 import ( - "errors" "net" ) var errClosed = net.ErrClosed - -func isErrClosed(err error) bool { - return errors.Is(err, errClosed) -} diff --git a/internal/jsonrpc2/serve_pre116.go b/internal/jsonrpc2/serve_pre116.go index 01b315f..584b9d8 100644 --- a/internal/jsonrpc2/serve_pre116.go +++ b/internal/jsonrpc2/serve_pre116.go @@ -9,22 +9,8 @@ package jsonrpc2 import ( "errors" - "strings" ) // errClosed is an error with the same string as net.ErrClosed, // which was added in Go 1.16. var errClosed = errors.New("use of closed network connection") - -// isErrClosed reports whether err ends in the same string as errClosed. -func isErrClosed(err error) bool { - // As of Go 1.16, this could be 'errors.Is(err, net.ErrClosing)', but - // unfortunately gopls still requires compatibility with - // (otherwise-unsupported) older Go versions. - // - // In the meantime, this error string has not changed on any supported Go - // version, and is not expected to change in the future. - // This is not ideal, but since the worst that could happen here is some - // superfluous logging, it is acceptable. - return strings.HasSuffix(err.Error(), "use of closed network connection") -}