all: Modernize error wrapping (#8491)

This replaces old style errors.Wrap with modern fmt.Errorf and removes
the (direct) dependency on github.com/pkg/errors. A couple of cases are
adjusted by hand as previously errors.Wrap(nil, ...) would return nil,
which is not what fmt.Errorf does.
This commit is contained in:
Jakob Borg
2022-08-16 10:01:49 +02:00
committed by GitHub
parent 75eeae0ee7
commit b10d106a55
23 changed files with 108 additions and 109 deletions
+5 -4
View File
@@ -10,9 +10,8 @@
package osutil
import (
"fmt"
"syscall"
"github.com/pkg/errors"
)
// SetLowPriority lowers the process CPU scheduling priority, and possibly
@@ -30,6 +29,8 @@ func SetLowPriority() error {
return nil
}
err := syscall.Setpriority(syscall.PRIO_PROCESS, pidSelf, wantNiceLevel)
return errors.Wrap(err, "set niceness") // wraps nil as nil
if err := syscall.Setpriority(syscall.PRIO_PROCESS, pidSelf, wantNiceLevel); err != nil {
return fmt.Errorf("set niceness: %w", err)
}
return nil
}