refactor: follow the google go style guide
Document every package and exported identifier, return the log level from NewLogger instead of keeping it in a package variable, and stop tests from mutating the argon2 parameters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
048e114fd9
commit
d20225982a
21 files changed
+147
-36
No files matched your search
@@ -1,3 +1,5 @@
|
||||
// Package migrations embeds the SQL schema migrations and applies them with
|
||||
// goose.
|
||||
package migrations
|
||||
|
||||
import (
|
||||
@@ -7,7 +9,7 @@ import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
_ "github.com/jackc/pgx/v5/stdlib" // registers the "pgx" database/sql driver
|
||||
"github.com/pressly/goose/v3"
|
||||
"github.com/pressly/goose/v3/lock"
|
||||
)
|
||||
@@ -40,30 +42,33 @@ func newProvider(dsn string) (*goose.Provider, *sql.DB, error) {
|
||||
return p, db, nil
|
||||
}
|
||||
|
||||
// Up applies all pending migrations.
|
||||
func Up(ctx context.Context, dsn string) ([]*goose.MigrationResult, error) {
|
||||
p, db, err := newProvider(dsn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("migrate: %w", err)
|
||||
}
|
||||
defer db.Close()
|
||||
defer func() { _ = db.Close() }()
|
||||
return p.Up(ctx)
|
||||
}
|
||||
|
||||
// Down rolls back the most recent migration.
|
||||
func Down(ctx context.Context, dsn string) (*goose.MigrationResult, error) {
|
||||
p, db, err := newProvider(dsn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("migrate: %w", err)
|
||||
}
|
||||
defer db.Close()
|
||||
defer func() { _ = db.Close() }()
|
||||
return p.Down(ctx)
|
||||
}
|
||||
|
||||
// Status lists every migration with its applied state.
|
||||
func Status(ctx context.Context, dsn string) ([]*goose.MigrationStatus, error) {
|
||||
p, db, err := newProvider(dsn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("migrate: %w", err)
|
||||
}
|
||||
defer db.Close()
|
||||
defer func() { _ = db.Close() }()
|
||||
return p.Status(ctx)
|
||||
}
|
||||
|
||||
@@ -74,6 +79,6 @@ func Pending(ctx context.Context, dsn string) (bool, error) {
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("migrate: %w", err)
|
||||
}
|
||||
defer db.Close()
|
||||
defer func() { _ = db.Close() }()
|
||||
return p.HasPending(ctx)
|
||||
}
|
||||
Reference in new issue
Block a user