diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-01-11 13:13:40 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-01-14 17:25:03 +0300 |
commit | 3b4390ac2ed5b9dbcc9efd3f8222a373d8db47bb (patch) | |
tree | fb38e4367c66106179af229d16b8f4c2fb32562f | |
parent | 3a4b9c6cb583685cdc4e17db61c919d4a7acce6a (diff) |
cmd/gitaly-wrapper: Modernize NumError assertion
When testing whether an error is recoverable or not, we verify that it
is either an ErrNotExist error or a number conversion error. The latter
is using a type assertion though, which isn't really en-vogue nowadays
anymore.
Convert the code to instead use `errors.As()`.
-rw-r--r-- | cmd/gitaly-wrapper/main.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd/gitaly-wrapper/main.go b/cmd/gitaly-wrapper/main.go index 3eeb55ad5..8cb0c3941 100644 --- a/cmd/gitaly-wrapper/main.go +++ b/cmd/gitaly-wrapper/main.go @@ -1,6 +1,7 @@ package main import ( + "errors" "fmt" "os" "os/exec" @@ -78,8 +79,8 @@ func main() { } func isRecoverable(err error) bool { - _, isNumError := err.(*strconv.NumError) - return os.IsNotExist(err) || isNumError + var numError *strconv.NumError + return os.IsNotExist(err) || errors.As(err, &numError) } func findGitaly() (*os.Process, error) { |