From 66625701105c6b38260fa4bbe465e0615135d018 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 16 Jun 2022 16:31:42 -0700 Subject: [PATCH 1/2] libct: fix staticcheck warning A new version of staticcheck (included into golangci-lint 1.46.2) gives this new warning: > libcontainer/factory_linux.go:230:59: SA9008: e refers to the result of a failed type assertion and is a zero value, not the value that was being type-asserted (staticcheck) > err = fmt.Errorf("panic from initialization: %v, %s", e, debug.Stack()) > ^ > libcontainer/factory_linux.go:226:7: SA9008(related information): this is the variable being read (staticcheck) > if e, ok := e.(error); ok { > ^ Apparently, this is indeed a bug. Fix by using a different name for a new variable, so we can access the old one under "else". Signed-off-by: Kir Kolyshkin --- libcontainer/factory_linux.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go index 17b05a55298..cd39ca38fae 100644 --- a/libcontainer/factory_linux.go +++ b/libcontainer/factory_linux.go @@ -223,10 +223,9 @@ func StartInitialization() (err error) { defer func() { if e := recover(); e != nil { - if e, ok := e.(error); ok { - err = fmt.Errorf("panic from initialization: %w, %s", e, debug.Stack()) + if ee, ok := e.(error); ok { + err = fmt.Errorf("panic from initialization: %w, %s", ee, debug.Stack()) } else { - //nolint:errorlint // here e is not of error type err = fmt.Errorf("panic from initialization: %v, %s", e, debug.Stack()) } } From 7481c3c97b67ae085cda4283191b1f002a22d601 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 16 Jun 2022 16:33:55 -0700 Subject: [PATCH 2/2] ci: bump golangci-lint to 1.46 Signed-off-by: Kir Kolyshkin --- .github/workflows/validate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 5a213409e58..8846215db36 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -32,7 +32,7 @@ jobs: sudo apt -q install libseccomp-dev - uses: golangci/golangci-lint-action@v3 with: - version: v1.45 + version: v1.46 # Extra linters, only checking new code from a pull request. - name: lint-extra if: github.event_name == 'pull_request'