mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
cleanup: avoid comparing errors directly
Go 1.13 contains support for error wrapping. To support wrapping, fmt.Errorf now has a %w verb for creating wrapped errors, and three new functions in the errors package ( errors.Unwrap, errors.Is and errors.As) simplify unwrapping and inspecting wrapped errors. With this change, If we currently compare errors using ==, we have to use errors.Is instead. Example: if err == io.ErrUnexpectedEOF becomes if errors.Is(err, io.ErrUnexpectedEOF) https://tip.golang.org/doc/go1.13#error_wrapping Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
e111f2b613
commit
323cc0e3bb
@ -62,7 +62,7 @@ func (nc *NodeCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) e
|
||||
cachePath := path.Join(nc.BasePath, nc.CacheDir)
|
||||
for _, file := range files {
|
||||
err = decodeObj(cachePath, pattern, file, destObj)
|
||||
if err == errDec {
|
||||
if errors.Is(err, errDec) {
|
||||
continue
|
||||
} else if err == nil {
|
||||
if err = f(strings.TrimSuffix(file.Name(), filepath.Ext(file.Name()))); err != nil {
|
||||
|
Reference in New Issue
Block a user