Update usage of os.IsNotExist (#29)

Per [godoc](https://pkg.go.dev/os#IsNotExist), this is the preferred method.
This commit is contained in:
Zach Wasserman 2021-08-04 10:04:27 -07:00 committed by GitHub
parent d56042de6a
commit ab3047bb39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -54,9 +54,9 @@ func (s *fileStore) GetMeta() (map[string]json.RawMessage, error) {
func (s *fileStore) readData() error {
stat, err := os.Stat(s.filename)
if err != nil && !os.IsNotExist(err) {
if err != nil && !errors.Is(err, os.ErrNotExist) {
return errors.Wrap(err, "stat file store")
} else if os.IsNotExist(err) {
} else if errors.Is(err, os.ErrNotExist) {
// initialize empty
s.metadata = metadataMap{}
return nil

View file

@ -235,7 +235,7 @@ func (u *Updater) Download(repoPath, localPath string) error {
if constant.PlatformName == "windows" {
// Remove old file first
if err := os.Rename(localPath, localPath+".old"); err != nil && !os.IsNotExist(err) {
if err := os.Rename(localPath, localPath+".old"); err != nil && !errors.Is(err, os.ErrNotExist) {
return errors.Wrap(err, "rename old")
}
}