mirror of
https://github.com/therootcompany/golib.git
synced 2026-04-24 12:48:00 +00:00
fix(shmigrate): use errors.Is for fs.ErrNotExist compatibility
os.IsNotExist does not recognize fs.ErrNotExist when wrapped by an fs.FS implementation. Switch to errors.Is(err, fs.ErrNotExist) so the "file not found" check works for both os.Open and fs.FS.Open.
This commit is contained in:
parent
55298ac018
commit
9c672a9d76
@ -2,6 +2,4 @@ module github.com/therootcompany/golib/database/sqlmigrate/shmigrate
|
||||
|
||||
go 1.26.1
|
||||
|
||||
require github.com/therootcompany/golib/database/sqlmigrate v0.0.0
|
||||
|
||||
replace github.com/therootcompany/golib/database/sqlmigrate => ../
|
||||
require github.com/therootcompany/golib/database/sqlmigrate v1.0.0
|
||||
|
||||
2
database/sqlmigrate/shmigrate/go.sum
Normal file
2
database/sqlmigrate/shmigrate/go.sum
Normal file
@ -0,0 +1,2 @@
|
||||
github.com/therootcompany/golib/database/sqlmigrate v1.0.0 h1:vehFGUBdv/su0jDzSNxYN7N7i1KE3l2QJDf4x9LXhwQ=
|
||||
github.com/therootcompany/golib/database/sqlmigrate v1.0.0/go.mod h1:7PQUjwT78Hx+SftcIKI2PH4zSFlrSO0V9h618PJqC38=
|
||||
@ -6,6 +6,7 @@ package shmigrate
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
@ -103,7 +104,7 @@ func (r *Migrator) Applied(ctx context.Context) ([]sqlmigrate.AppliedMigration,
|
||||
f, err = os.Open(r.LogPath)
|
||||
}
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("reading migrations log: %w", err)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user