Build on Go 1.27

go fix applied the modernizers. One rewrite it got wrong is corrected here: a
reverse loop over runes became a range over slices.Backward that bound the index
and the value to the SAME name, which does not compile and would have compared a
rune to an index if it had. The value gets its own name.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-09-17 06:18:28 -07:00
co-authored by Hanzo Dev
parent 5f20136b19
commit 85d7501b1f
25 changed files with 121 additions and 125 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ func (m *mockDriver) Drop() error {
func TestRegisterTwice(t *testing.T) {
Register("mock", &mockDriver{})
var err interface{}
var err any
func() {
defer func() {
err = recover()
+6 -6
View File
@@ -38,7 +38,7 @@ type Config struct {
type Neo4j struct {
driver neo4j.Driver
lock uint32
lock atomic.Uint32
// Open and WithInstance need to guarantee that config is never nil
config *Config
@@ -120,7 +120,7 @@ func (n *Neo4j) Close() error {
// local locking in order to pass tests, Neo doesn't support database locking
func (n *Neo4j) Lock() error {
if !atomic.CompareAndSwapUint32(&n.lock, 0, 1) {
if !n.lock.CompareAndSwap(0, 1) {
return database.ErrLocked
}
@@ -128,7 +128,7 @@ func (n *Neo4j) Lock() error {
}
func (n *Neo4j) Unlock() error {
if !atomic.CompareAndSwapUint32(&n.lock, 1, 0) {
if !n.lock.CompareAndSwap(1, 0) {
return database.ErrNotLocked
}
return nil
@@ -146,7 +146,7 @@ func (n *Neo4j) Run(migration io.Reader) (err error) {
}()
if n.config.MultiStatement {
_, err = session.WriteTransaction(func(transaction neo4j.Transaction) (interface{}, error) {
_, err = session.WriteTransaction(func(transaction neo4j.Transaction) (any, error) {
var stmtRunErr error
if err := multistmt.Parse(migration, StatementSeparator, n.config.MultiStatementMaxSize, func(stmt []byte) bool {
trimStmt := bytes.TrimSpace(stmt)
@@ -194,7 +194,7 @@ func (n *Neo4j) SetVersion(version int, dirty bool) (err error) {
query := fmt.Sprintf("MERGE (sm:%s {version: $version}) SET sm.dirty = $dirty, sm.ts = datetime()",
n.config.MigrationsLabel)
_, err = neo4j.Collect(session.Run(query, map[string]interface{}{"version": version, "dirty": dirty}))
_, err = neo4j.Collect(session.Run(query, map[string]any{"version": version, "dirty": dirty}))
if err != nil {
return err
}
@@ -220,7 +220,7 @@ func (n *Neo4j) Version() (version int, dirty bool, err error) {
query := fmt.Sprintf(`MATCH (sm:%s) RETURN sm.version AS version, sm.dirty AS dirty
ORDER BY COALESCE(sm.ts, datetime({year: 0})) DESC, sm.version DESC LIMIT 1`,
n.config.MigrationsLabel)
result, err := session.ReadTransaction(func(transaction neo4j.Transaction) (interface{}, error) {
result, err := session.ReadTransaction(func(transaction neo4j.Transaction) (any, error) {
result, err := transaction.Run(query, nil)
if err != nil {
return nil, err
+1 -1
View File
@@ -694,7 +694,7 @@ func TestWithInstance_Concurrent(t *testing.T) {
defer wg.Wait()
wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
for i := range concurrency {
go func(i int) {
defer wg.Done()
_, err := WithInstance(db, &Config{})
+1 -1
View File
@@ -669,7 +669,7 @@ func TestWithInstance_Concurrent(t *testing.T) {
defer wg.Wait()
wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
for i := range concurrency {
go func(i int) {
defer wg.Done()
_, err := WithInstance(db, &Config{})
+1 -1
View File
@@ -699,7 +699,7 @@ func testWithInstanceConcurrent(t *testing.T) {
defer wg.Wait()
wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
for i := range concurrency {
go func(i int) {
defer wg.Done()
_, err := WithInstance(db, &Config{})
+1 -1
View File
@@ -186,7 +186,7 @@ func (r *Rqlite) SetVersion(version int, dirty bool) error {
if version >= 0 || (version == database.NilVersion && dirty) {
statements = append(statements, gorqlite.ParameterizedStatement{
Query: insertQuery,
Arguments: []interface{}{
Arguments: []any{
version,
dirty,
},
+3 -2
View File
@@ -7,6 +7,7 @@ import (
"fmt"
"io"
nurl "net/url"
"slices"
"strconv"
"strings"
"sync/atomic"
@@ -231,8 +232,8 @@ func runesCount(input []rune, target rune) int {
}
func runesLastIndex(input []rune, target rune) int {
for i := len(input) - 1; i >= 0; i-- {
if input[i] == target {
for i, r := range slices.Backward(input) {
if r == target {
return i
}
}
+4 -3
View File
@@ -8,6 +8,7 @@ import (
"log"
nurl "net/url"
"regexp"
"slices"
"strconv"
"strings"
"sync/atomic"
@@ -202,7 +203,7 @@ func (s *Spanner) SetVersion(version int, dirty bool) error {
spanner.Delete(s.config.MigrationsTable, spanner.AllKeys()),
spanner.Insert(s.config.MigrationsTable,
[]string{"Version", "Dirty"},
[]interface{}{version, dirty},
[]any{version, dirty},
)}
return txn.BufferWrite(m)
})
@@ -261,8 +262,8 @@ func (s *Spanner) Drop() error {
}
stmts := make([]string, 0)
for i := len(res.Statements) - 1; i >= 0; i-- {
s := res.Statements[i]
for _, s := range slices.Backward(res.Statements) {
m := nameMatcher.FindSubmatch([]byte(s))
if len(m) == 0 {
+2 -2
View File
@@ -14,7 +14,7 @@ func init() {
type Stub struct {
Url string
Instance interface{}
Instance any
CurrentVersion int
MigrationSequence []string
LastRunMigration []byte // todo: make []string
@@ -35,7 +35,7 @@ func (s *Stub) Open(url string) (database.Driver, error) {
type Config struct{}
func WithInstance(instance interface{}, config *Config) (database.Driver, error) {
func WithInstance(instance any, config *Config) (database.Driver, error) {
return &Stub{
Instance: instance,
CurrentVersion: database.NilVersion,
-1
View File
@@ -45,7 +45,6 @@ func ParallelTest(t *testing.T, specs []ContainerSpec,
testFunc func(*testing.T, dktest.ContainerInfo)) {
for i, spec := range specs {
spec := spec // capture range variable, see https://goo.gl/60w3p2
// Only test against one version in short mode
// TODO: order is random, maybe always pick first version instead?
+56 -59
View File
@@ -1,6 +1,6 @@
module github.com/golang-migrate/migrate/v4
go 1.26.4
go 1.27.1
require (
cloud.google.com/go/spanner v1.85.0
@@ -29,6 +29,7 @@ require (
github.com/mutecomm/go-sqlcipher/v4 v4.4.0
github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8
github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba
github.com/rqlite/gorqlite v0.0.0-20230708021416-2acd02b70b79
github.com/snowflakedb/gosnowflake v1.19.1
github.com/stretchr/testify v1.11.1
github.com/xanzy/go-gitlab v0.15.0
@@ -42,68 +43,13 @@ require (
require (
cel.dev/expr v0.24.0 // indirect
cloud.google.com/go v0.121.6 // indirect
cloud.google.com/go/auth v0.16.4 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/monitoring v1.24.2 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.3 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.53.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.53.0 // indirect
github.com/apache/arrow-go/v18 v18.4.0 // indirect
github.com/aws/aws-sdk-go-v2/config v1.32.31 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.31 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.5.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.33.0 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.45.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/go-connections v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/hanzo-ds/native v0.71.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/montanaflynn/stats v0.6.6 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/paulmach/orb v0.12.0 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
github.com/zeebo/errs v1.4.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/detectors/gcp v1.36.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
go.opentelemetry.io/otel v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/sdk v1.40.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.40.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/telemetry v0.0.0-20251203150158-8fff8a5912fc // indirect
golang.org/x/tools v0.40.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
)
require (
cloud.google.com/go v0.121.6 // indirect
cloud.google.com/go/compute/metadata v0.8.0 // indirect
cloud.google.com/go/iam v1.5.2 // indirect
cloud.google.com/go/longrunning v0.6.7 // indirect
cloud.google.com/go/monitoring v1.24.2 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 // indirect
@@ -114,12 +60,20 @@ require (
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.3 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.53.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.53.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/andybalholm/brotli v1.2.0 // indirect
github.com/apache/arrow-go/v18 v18.4.0 // indirect
github.com/apache/thrift v0.22.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.43.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.14 // indirect
github.com/aws/aws-sdk-go-v2/config v1.32.31 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.19.30 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.31 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.35 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.31 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.31 // indirect
@@ -129,21 +83,38 @@ require (
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.31 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.32 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.106.0 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.5.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.33.0 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.45.0 // indirect
github.com/aws/smithy-go v1.27.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 // indirect
github.com/danieljoos/wincred v1.2.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.7.0 // indirect
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 // indirect
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@@ -158,12 +129,15 @@ require (
github.com/gorilla/mux v1.7.4 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hanzo-ds/native v0.71.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // 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.3.3 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/k0kubun/pp v2.3.0+incompatible // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
@@ -175,37 +149,59 @@ require (
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/montanaflynn/stats v0.6.6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/onsi/gomega v1.15.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/paulmach/orb v0.12.0 // indirect
github.com/pierrec/lz4/v4 v4.1.27 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rqlite/gorqlite v0.0.0-20230708021416-2acd02b70b79
github.com/segmentio/asm v1.2.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
github.com/zeebo/errs v1.4.0 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/detectors/gcp v1.36.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
go.opentelemetry.io/otel v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/sdk v1.40.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.40.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
golang.org/x/mod v0.31.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/telemetry v0.0.0-20251203150158-8fff8a5912fc // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/time v0.12.0 // indirect
golang.org/x/tools v0.40.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c // indirect
@@ -218,6 +214,7 @@ require (
modernc.org/db v1.0.0 // indirect
modernc.org/file v1.0.0 // indirect
modernc.org/fileutil v1.3.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/golex v1.0.0 // indirect
modernc.org/internal v1.0.0 // indirect
modernc.org/libc v1.41.0 // indirect
+3 -3
View File
@@ -12,7 +12,7 @@ type Log struct {
}
// Printf prints out formatted string into a log
func (l *Log) Printf(format string, v ...interface{}) {
func (l *Log) Printf(format string, v ...any) {
if l.verbose {
logpkg.Printf(format, v...)
} else {
@@ -21,7 +21,7 @@ func (l *Log) Printf(format string, v ...interface{}) {
}
// Println prints out args into a log
func (l *Log) Println(args ...interface{}) {
func (l *Log) Println(args ...any) {
if l.verbose {
logpkg.Println(args...)
} else {
@@ -34,7 +34,7 @@ func (l *Log) Verbose() bool {
return l.verbose
}
func (l *Log) fatal(args ...interface{}) {
func (l *Log) fatal(args ...any) {
l.Println(args...)
os.Exit(1)
}
+1 -1
View File
@@ -5,7 +5,7 @@ package migrate
type Logger interface {
// Printf is like fmt.Printf
Printf(format string, v ...interface{})
Printf(format string, v ...any)
// Verbose should return true when verbose logging output is wanted
Verbose() bool
+11 -11
View File
@@ -223,7 +223,7 @@ func (m *Migrate) Migrate(version uint) error {
return m.unlockErr(ErrDirty{curVersion})
}
ret := make(chan interface{}, m.PrefetchMigrations)
ret := make(chan any, m.PrefetchMigrations)
go m.read(curVersion, int(version), ret)
return m.unlockErr(m.runMigrations(ret))
@@ -249,7 +249,7 @@ func (m *Migrate) Steps(n int) error {
return m.unlockErr(ErrDirty{curVersion})
}
ret := make(chan interface{}, m.PrefetchMigrations)
ret := make(chan any, m.PrefetchMigrations)
if n > 0 {
go m.readUp(curVersion, n, ret)
@@ -276,7 +276,7 @@ func (m *Migrate) Up() error {
return m.unlockErr(ErrDirty{curVersion})
}
ret := make(chan interface{}, m.PrefetchMigrations)
ret := make(chan any, m.PrefetchMigrations)
go m.readUp(curVersion, -1, ret)
return m.unlockErr(m.runMigrations(ret))
@@ -298,7 +298,7 @@ func (m *Migrate) Down() error {
return m.unlockErr(ErrDirty{curVersion})
}
ret := make(chan interface{}, m.PrefetchMigrations)
ret := make(chan any, m.PrefetchMigrations)
go m.readDown(curVersion, -1, ret)
return m.unlockErr(m.runMigrations(ret))
}
@@ -336,7 +336,7 @@ func (m *Migrate) Run(migration ...*Migration) error {
return m.unlockErr(ErrDirty{curVersion})
}
ret := make(chan interface{}, m.PrefetchMigrations)
ret := make(chan any, m.PrefetchMigrations)
go func() {
defer close(ret)
@@ -397,7 +397,7 @@ func (m *Migrate) Version() (version uint, dirty bool, err error) {
// Each migration is then written to the ret channel.
// If an error occurs during reading, that error is written to the ret channel, too.
// Once read is done reading it will close the ret channel.
func (m *Migrate) read(from int, to int, ret chan<- interface{}) {
func (m *Migrate) read(from int, to int, ret chan<- any) {
defer close(ret)
// check if from version exists
@@ -529,7 +529,7 @@ func (m *Migrate) read(from int, to int, ret chan<- interface{}) {
// Each migration is then written to the ret channel.
// If an error occurs during reading, that error is written to the ret channel, too.
// Once readUp is done reading it will close the ret channel.
func (m *Migrate) readUp(from int, limit int, ret chan<- interface{}) {
func (m *Migrate) readUp(from int, limit int, ret chan<- any) {
defer close(ret)
// check if from version exists
@@ -629,7 +629,7 @@ func (m *Migrate) readUp(from int, limit int, ret chan<- interface{}) {
// Each migration is then written to the ret channel.
// If an error occurs during reading, that error is written to the ret channel, too.
// Once readDown is done reading it will close the ret channel.
func (m *Migrate) readDown(from int, limit int, ret chan<- interface{}) {
func (m *Migrate) readDown(from int, limit int, ret chan<- any) {
defer close(ret)
// check if from version exists
@@ -720,7 +720,7 @@ func (m *Migrate) readDown(from int, limit int, ret chan<- interface{}) {
// Before running a newly received migration it will check if it's supposed
// to stop execution because it might have received a stop signal on the
// GracefulStop channel.
func (m *Migrate) runMigrations(ret <-chan interface{}) error {
func (m *Migrate) runMigrations(ret <-chan any) error {
for r := range ret {
if m.stop() {
@@ -958,14 +958,14 @@ func (m *Migrate) unlockErr(prevErr error) error {
}
// logPrintf writes to m.Log if not nil
func (m *Migrate) logPrintf(format string, v ...interface{}) {
func (m *Migrate) logPrintf(format string, v ...any) {
if m.Log != nil {
m.Log.Printf(format, v...)
}
}
// logVerbosePrintf writes to m.Log if not nil. Use for verbose logging output.
func (m *Migrate) logVerbosePrintf(format string, v ...interface{}) {
func (m *Migrate) logVerbosePrintf(format string, v ...any) {
if m.Log != nil && m.Log.Verbose() {
m.Log.Printf(format, v...)
}
+5 -5
View File
@@ -1139,7 +1139,7 @@ func TestRead(t *testing.T) {
}
for i, v := range tt {
ret := make(chan interface{})
ret := make(chan any)
go m.read(v.from, v.to, ret)
migrations, err := migrationsFromChannel(ret)
@@ -1216,7 +1216,7 @@ func TestReadUp(t *testing.T) {
}
for i, v := range tt {
ret := make(chan interface{})
ret := make(chan any)
go m.readUp(v.from, v.limit, ret)
migrations, err := migrationsFromChannel(ret)
@@ -1293,7 +1293,7 @@ func TestReadDown(t *testing.T) {
}
for i, v := range tt {
ret := make(chan interface{})
ret := make(chan any)
go m.readDown(v.from, v.limit, ret)
migrations, err := migrationsFromChannel(ret)
@@ -1319,7 +1319,7 @@ func TestLock(t *testing.T) {
}
}
func migrationsFromChannel(ret chan interface{}) ([]*Migration, error) {
func migrationsFromChannel(ret chan any) ([]*Migration, error) {
slice := make([]*Migration, 0)
for r := range ret {
switch t := r.(type) {
@@ -1391,7 +1391,7 @@ func equalMigSeq(t *testing.T, i int, expected, got migrationSequence) {
t.Errorf("expected migrations %v, got %v, in %v", expected, got, i)
} else {
for ii := 0; ii < len(expected); ii++ {
for ii := range expected {
if expected[ii].Version != got[ii].Version {
t.Errorf("expected version %v, got %v, in %v", expected[ii].Version, got[ii].Version, i)
}
+5 -5
View File
@@ -77,9 +77,9 @@ func parseURI(uri string) (*Config, error) {
func (s *s3Driver) loadMigrations() error {
output, err := s.s3client.ListObjects(&s3.ListObjectsInput{
Bucket: aws.String(s.config.Bucket),
Prefix: aws.String(s.config.Prefix),
Delimiter: aws.String("/"),
Bucket: new(s.config.Bucket),
Prefix: new(s.config.Prefix),
Delimiter: new("/"),
})
if err != nil {
return err
@@ -142,8 +142,8 @@ func (s *s3Driver) ReadDown(version uint) (io.ReadCloser, string, error) {
func (s *s3Driver) open(m *source.Migration) (io.ReadCloser, string, error) {
key := path.Join(s.config.Prefix, m.Raw)
object, err := s.s3client.GetObject(&s3.GetObjectInput{
Bucket: aws.String(s.config.Bucket),
Key: aws.String(key),
Bucket: new(s.config.Bucket),
Key: new(key),
})
if err != nil {
return nil, "", err
+1 -1
View File
@@ -106,7 +106,7 @@ func (s *fakeS3) ListObjects(input *s3.ListObjectsInput) (*s3.ListObjectsOutput,
if strings.HasPrefix(name, prefix) {
if delimiter == "" || !strings.Contains(strings.Replace(name, prefix, "", 1), delimiter) {
output.Contents = append(output.Contents, &s3.Object{
Key: aws.String(name),
Key: new(name),
})
}
}
+1 -1
View File
@@ -156,7 +156,7 @@ func mustWriteFile(t testing.TB, dir, file string, body string) {
func mustCreateBenchmarkDir(t *testing.B) (dir string) {
tmpDir := t.TempDir()
for i := 0; i < 1000; i++ {
for i := range 1000 {
mustWriteFile(t, tmpDir, fmt.Sprintf("%v_foobar.up.sql", i), "")
mustWriteFile(t, tmpDir, fmt.Sprintf("%v_foobar.down.sql", i), "")
}
+3 -5
View File
@@ -85,11 +85,9 @@ func (g *Gitlab) Open(url string) (source.Driver, error) {
}
gn.listOptions = &gitlab.ListTreeOptions{
Path: &gn.path,
Ref: &u.Fragment,
ListOptions: gitlab.ListOptions{
PerPage: DefaultMaxItemsPerPage,
},
Path: &gn.path,
Ref: &u.Fragment,
PerPage: DefaultMaxItemsPerPage,
}
gn.getOptions = &gitlab.GetFileOptions{
@@ -66,7 +66,7 @@ func (fi bindataFileInfo) ModTime() time.Time {
func (fi bindataFileInfo) IsDir() bool {
return false
}
func (fi bindataFileInfo) Sys() interface{} {
func (fi bindataFileInfo) Sys() any {
return nil
}
@@ -227,8 +227,8 @@ func AssetDir(name string) ([]string, error) {
node := _bintree
if len(name) != 0 {
cannonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(cannonicalName, "/")
for _, p := range pathList {
pathList := strings.SplitSeq(cannonicalName, "/")
for p := range pathList {
node = node.Children[p]
if node == nil {
return nil, fmt.Errorf("Asset %s not found", name)
+1 -1
View File
@@ -41,7 +41,7 @@ var (
ErrNoAssetSource = fmt.Errorf("expects *AssetSource")
)
func WithInstance(instance interface{}) (source.Driver, error) {
func WithInstance(instance any) (source.Driver, error) {
if _, ok := instance.(*AssetSource); !ok {
return nil, ErrNoAssetSource
}
+7 -5
View File
@@ -300,11 +300,13 @@ var _bindata = map[string]func() (*asset, error){
// directory embedded in the file by go-bindata.
// For example if you run go-bindata on data/... and data contains the
// following hierarchy:
// data/
// foo.txt
// img/
// a.png
// b.png
//
// data/
// foo.txt
// img/
// a.png
// b.png
//
// then AssetDir("data") would return []string{"foo.txt", "img"}
// AssetDir("data/img") would return []string{"a.png", "b.png"}
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
+2 -3
View File
@@ -1,6 +1,7 @@
package source
import (
"slices"
"sort"
)
@@ -70,9 +71,7 @@ func (i *Migrations) buildIndex() {
for version := range i.migrations {
i.index = append(i.index, version)
}
sort.Slice(i.index, func(x, y int) bool {
return i.index[x] < i.index[y]
})
slices.Sort(i.index)
}
func (i *Migrations) First() (version uint, ok bool) {
+2 -2
View File
@@ -20,7 +20,7 @@ type Config struct{}
type Stub struct {
Url string
Instance interface{}
Instance any
Migrations *source.Migrations
Config *Config
}
@@ -33,7 +33,7 @@ func (s *Stub) Open(url string) (source.Driver, error) {
}, nil
}
func WithInstance(instance interface{}, config *Config) (source.Driver, error) {
func WithInstance(instance any, config *Config) (source.Driver, error) {
return &Stub{
Instance: instance,
Migrations: source.NewMigrations(),
-1
View File
@@ -27,7 +27,6 @@ func ParallelTest(t *testing.T, versions []Version, readyFn IsReadyFunc, testFn
}
for i, version := range versions {
version := version // capture range variable, see https://goo.gl/60w3p2
// Only test against one version in short mode
// TODO: order is random, maybe always pick first version instead?