Use errors.Is to check for a specific error

Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
This commit is contained in:
Fish-pro 2023-01-03 09:44:51 +08:00
parent 06fa41c401
commit 92c0f9c962
1 changed files with 2 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package genericresource
import (
"errors"
"fmt"
"net/url"
"os"
@ -158,7 +159,7 @@ func expandIfFilePattern(pattern string) ([]string, error) {
if err == nil && len(matches) == 0 {
return nil, fmt.Errorf("the path %q does not exist", pattern)
}
if err == filepath.ErrBadPattern {
if errors.Is(err, filepath.ErrBadPattern) {
return nil, fmt.Errorf("pattern %q is not valid: %v", pattern, err)
}
return matches, err