Minor fixes

This commit is contained in:
世界 2024-09-10 23:46:03 +08:00
parent 26511a251f
commit 0acb36c118
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 8 additions and 7 deletions

View file

@ -8,10 +8,6 @@ linters:
- paralleltest - paralleltest
- ineffassign - ineffassign
linters-settings: linters-settings:
gci: gci:
custom-order: true custom-order: true

View file

@ -1,17 +1,22 @@
package exceptions package exceptions
import "net" import (
"errors"
"net"
)
type TimeoutError interface { type TimeoutError interface {
Timeout() bool Timeout() bool
} }
func IsTimeout(err error) bool { func IsTimeout(err error) bool {
if netErr, isNetErr := err.(net.Error); isNetErr { var netErr net.Error
if errors.As(err, &netErr) {
//goland:noinspection GoDeprecation //goland:noinspection GoDeprecation
//nolint:staticcheck //nolint:staticcheck
return netErr.Temporary() && netErr.Timeout() return netErr.Temporary() && netErr.Timeout()
} else if timeoutErr, isTimeout := Cast[TimeoutError](err); isTimeout { }
if timeoutErr, isTimeout := Cast[TimeoutError](err); isTimeout {
return timeoutErr.Timeout() return timeoutErr.Timeout()
} }
return false return false