From dcea2f088ce10b1b0722c4eb995a4e145b5e9047 Mon Sep 17 00:00:00 2001 From: Brendan Creane Date: Wed, 29 Nov 2023 13:16:16 -0800 Subject: [PATCH] Remove noisy printf in NextReader() --- compression.go | 5 +---- conn.go | 9 ++------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/compression.go b/compression.go index 9fed0ef5..4630dba9 100644 --- a/compression.go +++ b/compression.go @@ -8,7 +8,6 @@ import ( "compress/flate" "errors" "io" - "log" "strings" "sync" ) @@ -135,9 +134,7 @@ func (r *flateReadWrapper) Read(p []byte) (int, error) { // Preemptively place the reader back in the pool. This helps with // scenarios where the application does not call NextReader() soon after // this final read. - if err := r.Close(); err != nil { - log.Printf("websocket: flateReadWrapper.Close() returned error: %v", err) - } + _ = r.Close() } return n, err } diff --git a/conn.go b/conn.go index 2a5ff76a..a19e5c4e 100644 --- a/conn.go +++ b/conn.go @@ -10,7 +10,6 @@ import ( "encoding/binary" "errors" "io" - "log" "net" "strconv" "strings" @@ -490,9 +489,7 @@ func (c *Conn) beginMessage(mw *messageWriter, messageType int) error { // probably better to return an error in this situation, but we cannot // change this without breaking existing applications. if c.writer != nil { - if err := c.writer.Close(); err != nil { - log.Printf("websocket: discarding writer close error: %v", err) - } + _ = c.writer.Close() c.writer = nil } @@ -1021,9 +1018,7 @@ func (c *Conn) handleProtocolError(message string) error { func (c *Conn) NextReader() (messageType int, r io.Reader, err error) { // Close previous reader, only relevant for decompression. if c.reader != nil { - if err := c.reader.Close(); err != nil { - log.Printf("websocket: discarding reader close error: %v", err) - } + _ = c.reader.Close() c.reader = nil }