mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
719886d435
Remove possible circular dependency that prevented us from using a real type. Signed-off-by: David Calavera <david.calavera@gmail.com>
21 lines
381 B
Go
21 lines
381 B
Go
package utils
|
|
|
|
import (
|
|
"net"
|
|
"net/url"
|
|
)
|
|
|
|
// IsTimeout takes an error returned from (generally) the http package and determines if it is a timeout error.
|
|
func IsTimeout(err error) bool {
|
|
switch e := err.(type) {
|
|
case net.Error:
|
|
return e.Timeout()
|
|
case *url.Error:
|
|
if t, ok := e.Err.(net.Error); ok {
|
|
return t.Timeout()
|
|
}
|
|
return false
|
|
default:
|
|
return false
|
|
}
|
|
}
|