Skip to content

Commit

Permalink
Fix for linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisberkhout committed Nov 4, 2024
1 parent f2c116e commit 53d69a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions internal/output/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package tcp

import (
"context"
"errors"
"io"
"net"
"time"
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions internal/output/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package tcp
import (
"context"
"crypto/tls"
"errors"
"io"
"net"
"time"
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 53d69a9

Please sign in to comment.