Drop isErrClosed
We require a new enough Go version now.
This commit is contained in:
parent
522f8a80d7
commit
7e891569b8
5
conn.go
5
conn.go
@ -2,6 +2,7 @@ package soju
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@ -163,7 +164,7 @@ func newConn(srv *Server, ic ircConn, options *connOptions) *conn {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err := c.conn.Close(); err != nil && !isErrClosed(err) {
|
||||
if err := c.conn.Close(); err != nil && !errors.Is(err, net.ErrClosed) {
|
||||
c.logger.Printf("failed to close connection: %v", err)
|
||||
} else {
|
||||
c.logger.Debugf("connection closed")
|
||||
@ -202,7 +203,7 @@ func (c *conn) Close() error {
|
||||
|
||||
func (c *conn) ReadMessage() (*irc.Message, error) {
|
||||
msg, err := c.conn.ReadMessage()
|
||||
if isErrClosed(err) {
|
||||
if errors.Is(err, net.ErrClosed) {
|
||||
return nil, io.EOF
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
|
12
net_go113.go
12
net_go113.go
@ -1,12 +0,0 @@
|
||||
//go:build !go1.16
|
||||
// +build !go1.16
|
||||
|
||||
package soju
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func isErrClosed(err error) bool {
|
||||
return err != nil && strings.Contains(err.Error(), "use of closed network connection")
|
||||
}
|
13
net_go116.go
13
net_go116.go
@ -1,13 +0,0 @@
|
||||
//go:build go1.16
|
||||
// +build go1.16
|
||||
|
||||
package soju
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
)
|
||||
|
||||
func isErrClosed(err error) bool {
|
||||
return errors.Is(err, net.ErrClosed)
|
||||
}
|
Loading…
Reference in New Issue
Block a user