espelhamento de
https://github.com/therootcompany/golib.git
sincronizado 2026-11-04 06:55: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.
Esse commit está contido em:
pai
55298ac018
commit
9c672a9d76
@ -2,6 +2,4 @@ module github.com/therootcompany/golib/database/sqlmigrate/shmigrate
|
|||||||
|
|
||||||
go 1.26.1
|
go 1.26.1
|
||||||
|
|
||||||
require github.com/therootcompany/golib/database/sqlmigrate v0.0.0
|
require github.com/therootcompany/golib/database/sqlmigrate v1.0.0
|
||||||
|
|
||||||
replace github.com/therootcompany/golib/database/sqlmigrate => ../
|
|
||||||
|
|||||||
2
database/sqlmigrate/shmigrate/go.sum
Arquivo normal
2
database/sqlmigrate/shmigrate/go.sum
Arquivo normal
@ -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 (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
@ -103,7 +104,7 @@ func (r *Migrator) Applied(ctx context.Context) ([]sqlmigrate.AppliedMigration,
|
|||||||
f, err = os.Open(r.LogPath)
|
f, err = os.Open(r.LogPath)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("reading migrations log: %w", err)
|
return nil, fmt.Errorf("reading migrations log: %w", err)
|
||||||
|
|||||||
Carregando…
x
Referência em uma nova issue
Block a user