Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
go-version-file: go.mod

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: v1.42.0
version: v2.11.4
args: --timeout 2m

go-build-and-test:
Expand Down
41 changes: 26 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
run:
version: "2"
linters:
enable:
- nilerr
- bodyclose
- gofmt
- revive
- govet
- gosec
linters-settings:
gofmt:
simplify: false
issues:
exclude-use-default: false
exclude:
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
# golint
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
- nilerr
- revive
exclusions:
generated: lax
rules:
- path: (.+)\.go$
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
- path: (.+)\.go$
text: func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
settings:
gofmt:
simplify: false
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
1 change: 0 additions & 1 deletion applied-migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type AppliedMigration struct {

// GetAppliedMigrations retrieves all already-applied migrations in a map keyed
// by the migration IDs
//
func (m Migrator) GetAppliedMigrations(db Queryer) (applied map[string]*AppliedMigration, err error) {
applied = make(map[string]*AppliedMigration)
migrations := make([]*AppliedMigration, 0)
Expand Down
1 change: 0 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
// pgxpool.Pool to its .Apply() method.
//
// See the package's README.md file for more usage instructions.
//
package pgxschema
3 changes: 1 addition & 2 deletions embed_go116.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import (
//
// Example usage:
//
// FSMigrations(embeddedFS, "my-migrations/*.sql")
//
// FSMigrations(embeddedFS, "my-migrations/*.sql")
func FSMigrations(filesystem fs.FS, glob string) (migrations []*Migration, err error) {
migrations = make([]*Migration, 0)

Expand Down
4 changes: 2 additions & 2 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package pgxschema
import "fmt"

// ErrNilDB is thrown when the database pointer is nil
var ErrNilDB = fmt.Errorf("Database connection is nil")
var ErrNilDB = fmt.Errorf("database connection is nil")

// ErrNilTx is thrown when a command is run against a nil transaction
var ErrNilTx = fmt.Errorf("Database transaction is nil")
var ErrNilTx = fmt.Errorf("database transaction is nil")
4 changes: 2 additions & 2 deletions errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
// verify the "right" failure occurred.
type BadQueryer struct{}

func (bq BadQueryer) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error) {
func (bq BadQueryer) Exec(_ context.Context, sql string, _ ...interface{}) (pgconn.CommandTag, error) {
return []byte{}, fmt.Errorf("FAIL: %s", strings.TrimSpace(sql))
}

func (bq BadQueryer) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) {
func (bq BadQueryer) Query(_ context.Context, sql string, _ ...interface{}) (pgx.Rows, error) {
return nil, fmt.Errorf("FAIL: %s", strings.TrimSpace(sql))
}

Expand Down
7 changes: 3 additions & 4 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package pgxschema

import (
"fmt"
"io/ioutil"
"io"
"os"
"path"
"path/filepath"
Expand All @@ -11,7 +11,6 @@ import (

// MigrationIDFromFilename removes directory paths and extensions
// from the filename to make a friendlier Migration ID
//
func MigrationIDFromFilename(filename string) string {
return strings.TrimSuffix(filepath.Base(filename), filepath.Ext(filename))
}
Expand Down Expand Up @@ -48,7 +47,7 @@ func MigrationsFromDirectoryPath(dirPath string) (migrations []*Migration, err e
func MigrationFromFilePath(filename string) (migration *Migration, err error) {
migration = &Migration{}
migration.ID = MigrationIDFromFilename(filename)
contents, err := ioutil.ReadFile(path.Clean(filename))
contents, err := os.ReadFile(path.Clean(filename))
if err != nil {
return migration, fmt.Errorf("failed to read migration from '%s': %w", filename, err)
}
Expand All @@ -68,7 +67,7 @@ type File interface {
func MigrationFromFile(file File) (migration *Migration, err error) {
migration = &Migration{}
migration.ID = MigrationIDFromFilename(file.Name())
content, err := ioutil.ReadAll(file)
content, err := io.ReadAll(file)
if err != nil {
return migration, err
}
Expand Down
2 changes: 1 addition & 1 deletion file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (fr failedReader) Name() string {
return "fakeFile.sql"
}

func (fr failedReader) Read(p []byte) (n int, err error) {
func (fr failedReader) Read(_ []byte) (n int, err error) {
return 0, errors.New("this reader always fails")
}

Expand Down
73 changes: 42 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,48 +1,59 @@
module github.com/adlio/pgxschema

go 1.17
go 1.25.0

require (
github.com/jackc/pgconn v1.10.1
github.com/jackc/pgx/v4 v4.14.1
github.com/ory/dockertest/v3 v3.9.1
github.com/pashagolub/pgxmock v1.4.3
github.com/jackc/pgconn v1.14.3
github.com/jackc/pgx/v4 v4.18.3
github.com/ory/dockertest/v3 v3.12.0
github.com/pashagolub/pgxmock v1.8.0
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
dario.cat/mergo v1.0.2 // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/docker/cli v20.10.17+incompatible // indirect
github.com/docker/docker v20.10.17+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/continuity v0.5.0 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/cli v29.4.1+incompatible // indirect
github.com/docker/go-connections v0.7.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.2.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.9.1 // indirect
github.com/jackc/puddle v1.2.0 // indirect
github.com/lib/pq v1.10.3 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgtype v1.14.4 // indirect
github.com/jackc/puddle v1.3.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/moby/api v1.54.2 // indirect
github.com/moby/moby/client v0.4.1 // indirect
github.com/moby/sys/user v0.4.0 // indirect
github.com/moby/term v0.5.2 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runc v1.1.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/opencontainers/runc v1.2.3 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b // indirect
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.50.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/text v0.36.0 // indirect
)
Loading
Loading