Skip to content

Commit

Permalink
lib/fs: Use io/fs errors as recommended in std lib
Browse files Browse the repository at this point in the history
  • Loading branch information
imsodin committed Dec 21, 2022
1 parent f0126fe commit a63a95a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/fs/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"context"
"errors"
"io"
"io/fs"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -192,20 +193,25 @@ const OptWriteOnly = os.O_WRONLY
// as an error by any function.
var SkipDir = filepath.SkipDir

// IsExist is the equivalent of os.IsExist
var IsExist = os.IsExist
func IsExist(err error) bool {
return errors.Is(err, ErrExist)
}

// IsExist is the equivalent of os.ErrExist
var ErrExist = os.ErrExist
// ErrExist is the equivalent of os.ErrExist
var ErrExist = fs.ErrExist

// IsNotExist is the equivalent of os.IsNotExist
var IsNotExist = os.IsNotExist
func IsNotExist(err error) bool {
return errors.Is(err, ErrNotExist)
}

// ErrNotExist is the equivalent of os.ErrNotExist
var ErrNotExist = os.ErrNotExist
var ErrNotExist = fs.ErrNotExist

// IsPermission is the equivalent of os.IsPermission
var IsPermission = os.IsPermission
func IsPermission(err error) bool {
return errors.Is(err, fs.ErrPermission)
}

// IsPathSeparator is the equivalent of os.IsPathSeparator
var IsPathSeparator = os.IsPathSeparator
Expand Down

0 comments on commit a63a95a

Please sign in to comment.