From 907aefd43cd91d4452ca79f0aea8b6ae594c6e95 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 15 Dec 2021 17:00:06 -0800 Subject: [PATCH] libct: StartInitialization: fix %w related warning (on Go 1.18 this is actually an error) > libcontainer/factory_linux.go:341:10: fmt.Errorf format %w has arg e of wrong type interface{} Unfortunately, fixing it results in an errorlint warning: > libcontainer/factory_linux.go#L344 non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint) so we have to silence that one. Signed-off-by: Kir Kolyshkin --- libcontainer/factory_linux.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go index 023d623f3..e6c71ac34 100644 --- a/libcontainer/factory_linux.go +++ b/libcontainer/factory_linux.go @@ -338,7 +338,12 @@ func (l *LinuxFactory) StartInitialization() (err error) { defer func() { if e := recover(); e != nil { - err = fmt.Errorf("panic from initialization: %w, %v", e, string(debug.Stack())) + if e, ok := e.(error); ok { + err = fmt.Errorf("panic from initialization: %w, %s", e, debug.Stack()) + } else { + //nolint:errorlint // here e is not of error type + err = fmt.Errorf("panic from initialization: %v, %s", e, debug.Stack()) + } } }()