diff --git a/netctx/conn.go b/netctx/conn.go index d13a177..a3322dc 100644 --- a/netctx/conn.go +++ b/netctx/conn.go @@ -68,7 +68,7 @@ func (c *conn) ReadContext(ctx context.Context, b []byte) (int, error) { select { case <-c.closed: - return 0, io.EOF + return 0, net.ErrClosed default: } diff --git a/netctx/conn_test.go b/netctx/conn_test.go index d3f2c92..4c920c2 100644 --- a/netctx/conn_test.go +++ b/netctx/conn_test.go @@ -97,8 +97,8 @@ func TestReadClosed(t *testing.T) { b := make([]byte, 100) n, err := c.ReadContext(context.Background(), b) - if !errors.Is(err, io.EOF) { - t.Errorf("Expected error '%v', got '%v'", io.EOF, err) + if !errors.Is(err, net.ErrClosed) { + t.Errorf("Expected error '%v', got '%v'", net.ErrClosed, err) } if n != 0 { t.Errorf("Wrong data length, expected %d, got %d", 0, n) diff --git a/netctx/packetconn.go b/netctx/packetconn.go index b158cf0..1b65276 100644 --- a/netctx/packetconn.go +++ b/netctx/packetconn.go @@ -54,7 +54,7 @@ func (p *packetConn) ReadFromContext(ctx context.Context, b []byte) (int, net.Ad select { case <-p.closed: - return 0, nil, io.EOF + return 0, nil, net.ErrClosed default: } diff --git a/netctx/packetconn_test.go b/netctx/packetconn_test.go index 747c84b..f1fd571 100644 --- a/netctx/packetconn_test.go +++ b/netctx/packetconn_test.go @@ -141,8 +141,8 @@ func TestReadFromClosed(t *testing.T) { b := make([]byte, 100) n, _, err := c.ReadFromContext(context.Background(), b) - if !errors.Is(err, io.EOF) { - t.Errorf("Expected error '%v', got '%v'", io.EOF, err) + if !errors.Is(err, net.ErrClosed) { + t.Errorf("Expected error '%v', got '%v'", net.ErrClosed, err) } if n != 0 { t.Errorf("Wrong data length, expected %d, got %d", 0, n)