Skip to content

Commit

Permalink
Use errors.Is(...) instead of os.Is...() in migrate.go: golang/go#41122
Browse files Browse the repository at this point in the history
  • Loading branch information
leventov committed Aug 29, 2020
1 parent 945ada5 commit 04fb8d6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions migrate.go
Expand Up @@ -487,7 +487,7 @@ func (m *Migrate) read(from int, to int, ret chan<- interface{}) {
}

prev, err := m.sourceDrv.Prev(suint(from))
if os.IsNotExist(err) && to == -1 {
if errors.Is(err, os.ErrNotExist) && to == -1 {
// apply nil migration
migr, err := m.newMigration(suint(from), -1)
if err != nil {
Expand Down Expand Up @@ -580,7 +580,7 @@ func (m *Migrate) readUp(from int, limit int, ret chan<- interface{}) {

// apply next migration
next, err := m.sourceDrv.Next(suint(from))
if os.IsNotExist(err) {
if errors.Is(err, os.ErrNotExist) {
// no limit, but no migrations applied?
if limit == -1 && count == 0 {
ret <- ErrNoChange
Expand Down Expand Up @@ -666,7 +666,7 @@ func (m *Migrate) readDown(from int, limit int, ret chan<- interface{}) {
}

prev, err := m.sourceDrv.Prev(suint(from))
if os.IsNotExist(err) {
if errors.Is(err, os.ErrNotExist) {
// no limit or haven't reached limit, apply "first" migration
if limit == -1 || limit-count > 0 {
firstVersion, err := m.sourceDrv.First()
Expand Down Expand Up @@ -785,9 +785,9 @@ func (m *Migrate) versionExists(version uint) (result error) {
}
}()
}
if os.IsExist(err) {
if errors.Is(err, os.ErrExist) {
return nil
} else if !os.IsNotExist(err) {
} else if !errors.Is(err, os.ErrNotExist) {
return err
}

Expand All @@ -800,9 +800,9 @@ func (m *Migrate) versionExists(version uint) (result error) {
}
}()
}
if os.IsExist(err) {
if errors.Is(err, os.ErrExist) {
return nil
} else if !os.IsNotExist(err) {
} else if !errors.Is(err, os.ErrNotExist) {
return err
}

Expand Down Expand Up @@ -836,7 +836,7 @@ func (m *Migrate) newMigration(version uint, targetVersion int) (*Migration, err

if targetVersion >= int(version) {
r, identifier, err := m.sourceDrv.ReadUp(version)
if os.IsNotExist(err) {
if errors.Is(err, os.ErrNotExist) {
// create "empty" migration
migr, err = NewMigration(nil, "", version, targetVersion)
if err != nil {
Expand All @@ -856,7 +856,7 @@ func (m *Migrate) newMigration(version uint, targetVersion int) (*Migration, err

} else {
r, identifier, err := m.sourceDrv.ReadDown(version)
if os.IsNotExist(err) {
if errors.Is(err, os.ErrNotExist) {
// create "empty" migration
migr, err = NewMigration(nil, "", version, targetVersion)
if err != nil {
Expand Down

0 comments on commit 04fb8d6

Please sign in to comment.