aboutsummaryrefslogtreecommitdiff
path: root/fasthttputil/inmemory_listener.go
diff options
context:
space:
mode:
Diffstat (limited to 'fasthttputil/inmemory_listener.go')
-rw-r--r--fasthttputil/inmemory_listener.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/fasthttputil/inmemory_listener.go b/fasthttputil/inmemory_listener.go
index 1b1a5f3..fd41fc8 100644
--- a/fasthttputil/inmemory_listener.go
+++ b/fasthttputil/inmemory_listener.go
@@ -1,11 +1,13 @@
package fasthttputil
import (
- "fmt"
+ "errors"
"net"
"sync"
)
+var ErrInmemoryListenerClosed = errors.New("InmemoryListener is already closed: use of closed network connection")
+
// InmemoryListener provides in-memory dialer<->net.Listener implementation.
//
// It may be used either for fast in-process client<->server communications
@@ -36,7 +38,7 @@ func NewInmemoryListener() *InmemoryListener {
func (ln *InmemoryListener) Accept() (net.Conn, error) {
c, ok := <-ln.conns
if !ok {
- return nil, fmt.Errorf("InmemoryListener is already closed: use of closed network connection")
+ return nil, ErrInmemoryListenerClosed
}
close(c.accepted)
return c.conn, nil
@@ -51,7 +53,7 @@ func (ln *InmemoryListener) Close() error {
close(ln.conns)
ln.closed = true
} else {
- err = fmt.Errorf("InmemoryListener is already closed")
+ err = ErrInmemoryListenerClosed
}
ln.lock.Unlock()
return err
@@ -88,7 +90,7 @@ func (ln *InmemoryListener) Dial() (net.Conn, error) {
ln.lock.Unlock()
if cConn == nil {
- return nil, fmt.Errorf("InmemoryListener is already closed")
+ return nil, ErrInmemoryListenerClosed
}
return cConn, nil
}