From 53d69a9ff1d7cd22ec7942941378e698dd1264fb Mon Sep 17 00:00:00 2001 From: Chris Berkhout Date: Mon, 4 Nov 2024 18:25:46 +0100 Subject: [PATCH] Fix for linter. --- internal/output/tcp/tcp.go | 7 +++++-- internal/output/tls/tls.go | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/output/tcp/tcp.go b/internal/output/tcp/tcp.go index 1de97e9..4228310 100644 --- a/internal/output/tcp/tcp.go +++ b/internal/output/tcp/tcp.go @@ -6,6 +6,7 @@ package tcp import ( "context" + "errors" "io" "net" "time" @@ -44,7 +45,9 @@ func (o *Output) Conn() net.Conn { func (o *Output) Close() error { if o.conn != nil { - o.conn.CloseWrite() + if err := o.conn.CloseWrite(); err != nil { + return err + } // drain to facilitate graceful close on the other side deadline := time.Now().Add(5 * time.Second) @@ -54,7 +57,7 @@ func (o *Output) Close() error { buffer := make([]byte, 1024) for { _, err := o.conn.Read(buffer) - if err == io.EOF { + if errors.Is(err, io.EOF) { break } else if err != nil { return err diff --git a/internal/output/tls/tls.go b/internal/output/tls/tls.go index 9e7523d..f146ade 100644 --- a/internal/output/tls/tls.go +++ b/internal/output/tls/tls.go @@ -7,6 +7,7 @@ package tcp import ( "context" "crypto/tls" + "errors" "io" "net" "time" @@ -46,7 +47,9 @@ func (o *Output) DialContext(ctx context.Context) error { func (o *Output) Close() error { if o.conn != nil { - o.conn.CloseWrite() + if err := o.conn.CloseWrite(); err != nil { + return err + } // drain to facilitate graceful close on the other side deadline := time.Now().Add(5 * time.Second) @@ -56,7 +59,7 @@ func (o *Output) Close() error { buffer := make([]byte, 1024) for { _, err := o.conn.Read(buffer) - if err == io.EOF { + if errors.Is(err, io.EOF) { break } else if err != nil { return err