From 0acb36c118b799dde6817723e732bc670c21e8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 10 Sep 2024 23:46:03 +0800 Subject: [PATCH] Minor fixes --- .golangci.yml | 4 ---- common/exceptions/timeout.go | 11 ++++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 13a8575..fb42693 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,10 +8,6 @@ linters: - paralleltest - ineffassign - - - - linters-settings: gci: custom-order: true diff --git a/common/exceptions/timeout.go b/common/exceptions/timeout.go index fbd8946..f2ae6c3 100644 --- a/common/exceptions/timeout.go +++ b/common/exceptions/timeout.go @@ -1,17 +1,22 @@ package exceptions -import "net" +import ( + "errors" + "net" +) type TimeoutError interface { Timeout() 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 //nolint:staticcheck return netErr.Temporary() && netErr.Timeout() - } else if timeoutErr, isTimeout := Cast[TimeoutError](err); isTimeout { + } + if timeoutErr, isTimeout := Cast[TimeoutError](err); isTimeout { return timeoutErr.Timeout() } return false