1
0
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:
AJ ONeal 2026-04-08 17:52:53 -06:00
commit 9c672a9d76
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados
3 arquivos alterados com 5 adições e 4 exclusões

Ver arquivo

@ -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 => ../

Ver arquivo

@ -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=

Ver arquivo

@ -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)