Procházet zdrojové kódy

Just use net.Error

Brad Fitzpatrick před 11 roky
rodič
revize
76a77964a7
1 změnil soubory, kde provedl 2 přidání a 8 odebrání
  1. 2 8
      memcache/memcache.go

+ 2 - 8
memcache/memcache.go

@@ -234,10 +234,6 @@ type ConnectTimeoutError struct {
 	Addr net.Addr
 }
 
-type netConnectionTimeoutError interface {
-	Timeout() bool
-}
-
 func (cte *ConnectTimeoutError) Error() string {
 	return "memcache: connect timeout to " + cte.Addr.String()
 }
@@ -253,10 +249,8 @@ func (c *Client) dial(addr net.Addr) (net.Conn, error) {
 		return nc, nil
 	}
 
-	if terr, ok := err.(netConnectionTimeoutError); ok {
-		if terr.Timeout() {
-			return nil, &ConnectTimeoutError{addr}
-		}
+	if ne, ok := err.(net.Error); ok && ne.Timeout() {
+		return nil, &ConnectTimeoutError{addr}
 	}
 
 	return nil, err