Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-01-11 13:13:40 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-01-14 17:25:03 +0300
commit3b4390ac2ed5b9dbcc9efd3f8222a373d8db47bb (patch)
treefb38e4367c66106179af229d16b8f4c2fb32562f
parent3a4b9c6cb583685cdc4e17db61c919d4a7acce6a (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.go5
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) {