From 48b357e78c16ea4e009f037fc06caedeebee6a95 Mon Sep 17 00:00:00 2001 From: Simon Blixenkrone Date: Fri, 3 May 2024 13:59:05 +0200 Subject: [PATCH] check for net error closed error instead of hack --- agent/agent.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 07a3e80b..533141f4 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -22,7 +22,6 @@ import ( "runtime/pprof" "runtime/trace" "strconv" - "strings" "sync" "syscall" "time" @@ -120,8 +119,7 @@ func listen(l net.Listener) { for { fd, err := l.Accept() if err != nil { - // No great way to check for this, see https://golang.org/issues/4373. - if !strings.Contains(err.Error(), "use of closed network connection") { + if !errors.Is(err, net.ErrClosed) { fmt.Fprintf(os.Stderr, "gops: %v\n", err) } if netErr, ok := err.(net.Error); ok && !netErr.Temporary() {