diff --git a/cli/commands.go b/cli/commands.go index 703896dc..a950d1a0 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -1,11 +1,11 @@ package main import ( + "fmt" "github.com/mattes/migrate" _ "github.com/mattes/migrate/database/stub" // TODO remove again _ "github.com/mattes/migrate/source/file" "os" - "fmt" ) func createCmd(dir string, timestamp int64, name string, ext string) { @@ -16,9 +16,9 @@ func createCmd(dir string, timestamp int64, name string, ext string) { } func createFile(fname string) { - if _, err := os.Create(fname); err != nil { - log.fatalErr(err) - } + if _, err := os.Create(fname); err != nil { + log.fatalErr(err) + } } func gotoCmd(m *migrate.Migrate, v uint) { diff --git a/database/cassandra/cassandra_test.go b/database/cassandra/cassandra_test.go index 4ca764a0..912fc888 100644 --- a/database/cassandra/cassandra_test.go +++ b/database/cassandra/cassandra_test.go @@ -2,12 +2,12 @@ package cassandra import ( "fmt" - "testing" + "github.com/gocql/gocql" dt "github.com/mattes/migrate/database/testing" mt "github.com/mattes/migrate/testing" - "github.com/gocql/gocql" - "time" "strconv" + "testing" + "time" ) var versions = []mt.Version{ diff --git a/database/cockroachdb/cockroachdb.go b/database/cockroachdb/cockroachdb.go index 50ae8f4d..a4dbe91c 100644 --- a/database/cockroachdb/cockroachdb.go +++ b/database/cockroachdb/cockroachdb.go @@ -7,13 +7,13 @@ import ( "io/ioutil" nurl "net/url" + "context" "github.com/cockroachdb/cockroach-go/crdb" "github.com/lib/pq" "github.com/mattes/migrate" "github.com/mattes/migrate/database" "regexp" "strconv" - "context" ) func init() { @@ -33,8 +33,8 @@ var ( type Config struct { MigrationsTable string - LockTable string - ForceLock bool + LockTable string + ForceLock bool DatabaseName string } @@ -126,8 +126,8 @@ func (c *CockroachDb) Open(url string) (database.Driver, error) { px, err := WithInstance(db, &Config{ DatabaseName: purl.Path, MigrationsTable: migrationsTable, - LockTable: lockTable, - ForceLock: forceLock, + LockTable: lockTable, + ForceLock: forceLock, }) if err != nil { return nil, err @@ -163,7 +163,7 @@ func (c *CockroachDb) Lock() error { } query = "INSERT INTO " + c.config.LockTable + " (lock_id) VALUES ($1)" - if _, err := tx.Exec(query, aid) ; err != nil { + if _, err := tx.Exec(query, aid); err != nil { return database.Error{OrigErr: err, Err: "failed to set migration lock", Query: []byte(query)} } @@ -228,7 +228,7 @@ func (c *CockroachDb) SetVersion(version int, dirty bool) error { } if version >= 0 { - if _, err := tx.Exec(`INSERT INTO "` + c.config.MigrationsTable + `" (version, dirty) VALUES ($1, $2)`, version, dirty); err != nil { + if _, err := tx.Exec(`INSERT INTO "`+c.config.MigrationsTable+`" (version, dirty) VALUES ($1, $2)`, version, dirty); err != nil { return err } } @@ -316,7 +316,6 @@ func (c *CockroachDb) ensureVersionTable() error { return nil } - func (c *CockroachDb) ensureLockTable() error { // check if lock table exists var count int diff --git a/database/cockroachdb/cockroachdb_test.go b/database/cockroachdb/cockroachdb_test.go index e2dc1f86..96a45885 100644 --- a/database/cockroachdb/cockroachdb_test.go +++ b/database/cockroachdb/cockroachdb_test.go @@ -9,10 +9,10 @@ import ( "io" "testing" + "bytes" "github.com/lib/pq" dt "github.com/mattes/migrate/database/testing" mt "github.com/mattes/migrate/testing" - "bytes" ) var versions = []mt.Version{ @@ -28,7 +28,7 @@ func isReady(i mt.Instance) bool { err = db.Ping() if err == io.EOF { _, err = db.Exec("CREATE DATABASE migrate") - return err == nil; + return err == nil } else if e, ok := err.(*pq.Error); ok { if e.Code.Name() == "cannot_connect_now" { return false @@ -36,7 +36,7 @@ func isReady(i mt.Instance) bool { } _, err = db.Exec("CREATE DATABASE migrate") - return err == nil; + return err == nil return true } diff --git a/testing/docker.go b/testing/docker.go index f7a7c415..51a8fe38 100644 --- a/testing/docker.go +++ b/testing/docker.go @@ -6,16 +6,16 @@ import ( "context" "encoding/json" "fmt" + dockertypes "github.com/docker/docker/api/types" + dockercontainer "github.com/docker/docker/api/types/container" + dockernetwork "github.com/docker/docker/api/types/network" + dockerclient "github.com/docker/docker/client" "io" "math/rand" "strconv" "strings" "testing" "time" - dockertypes "github.com/docker/docker/api/types" - dockercontainer "github.com/docker/docker/api/types/container" - dockernetwork "github.com/docker/docker/api/types/network" - dockerclient "github.com/docker/docker/client" ) func NewDockerContainer(t testing.TB, image string, env []string, cmd []string) (*DockerContainer, error) { @@ -33,7 +33,7 @@ func NewDockerContainer(t testing.TB, image string, env []string, cmd []string) client: c, ImageName: image, ENV: env, - Cmd: cmd, + Cmd: cmd, } if err := contr.PullImage(); err != nil { diff --git a/testing/testing.go b/testing/testing.go index 64e0a646..06c69b28 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -49,8 +49,8 @@ func ParallelTest(t *testing.T, versions []Version, readyFn IsReadyFunc, testFn // wait until database is ready tick := time.Tick(1000 * time.Millisecond) - timeout := time.After(time.Duration(delay + 60) * time.Second) - outer: + timeout := time.After(time.Duration(delay+60) * time.Second) + outer: for { select { case <-tick: