diff --git a/compression.go b/compression.go index fe1079ed..c5a8a63a 100644 --- a/compression.go +++ b/compression.go @@ -20,7 +20,7 @@ const ( var ( flateWriterPools [maxCompressionLevel - minCompressionLevel + 1]sync.Pool - flateReaderPool = sync.Pool{New: func() interface{} { + flateReaderPool = sync.Pool{New: func() any { return flate.NewReader(nil) }} ) diff --git a/conn.go b/conn.go index 9562ffd4..7ab1c62a 100644 --- a/conn.go +++ b/conn.go @@ -227,9 +227,9 @@ func isValidReceivedCloseCode(code int) bool { // interface. The type of the value stored in a pool is not specified. type BufferPool interface { // Get gets a value from the pool or returns nil if the pool is empty. - Get() interface{} + Get() any // Put adds a value to the pool. - Put(interface{}) + Put(any) } // writePoolData is the type added to the write buffer pool. This wrapper is diff --git a/conn_test.go b/conn_test.go index 28f5c4a3..cb35f035 100644 --- a/conn_test.go +++ b/conn_test.go @@ -227,16 +227,16 @@ func TestControl(t *testing.T) { // simpleBufferPool is an implementation of BufferPool for TestWriteBufferPool. type simpleBufferPool struct { - v interface{} + v any } -func (p *simpleBufferPool) Get() interface{} { +func (p *simpleBufferPool) Get() any { v := p.v p.v = nil return v } -func (p *simpleBufferPool) Put(v interface{}) { +func (p *simpleBufferPool) Put(v any) { p.v = v } diff --git a/json.go b/json.go index dc2c1f64..123b7184 100644 --- a/json.go +++ b/json.go @@ -12,7 +12,7 @@ import ( // WriteJSON writes the JSON encoding of v as a message. // // Deprecated: Use c.WriteJSON instead. -func WriteJSON(c *Conn, v interface{}) error { +func WriteJSON(c *Conn, v any) error { return c.WriteJSON(v) } @@ -20,7 +20,7 @@ func WriteJSON(c *Conn, v interface{}) error { // // See the documentation for encoding/json Marshal for details about the // conversion of Go values to JSON. -func (c *Conn) WriteJSON(v interface{}) error { +func (c *Conn) WriteJSON(v any) error { w, err := c.NextWriter(TextMessage) if err != nil { return err @@ -37,7 +37,7 @@ func (c *Conn) WriteJSON(v interface{}) error { // it in the value pointed to by v. // // Deprecated: Use c.ReadJSON instead. -func ReadJSON(c *Conn, v interface{}) error { +func ReadJSON(c *Conn, v any) error { return c.ReadJSON(v) } @@ -46,7 +46,7 @@ func ReadJSON(c *Conn, v interface{}) error { // // See the documentation for the encoding/json Unmarshal function for details // about the conversion of JSON to a Go value. -func (c *Conn) ReadJSON(v interface{}) error { +func (c *Conn) ReadJSON(v any) error { _, r, err := c.NextReader() if err != nil { return err