Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

gofmt #352

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

gofmt #352

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions 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) {
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions database/cassandra/cassandra_test.go
Expand Up @@ -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{
Expand Down
15 changes: 7 additions & 8 deletions database/cockroachdb/cockroachdb.go
Expand Up @@ -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() {
Expand All @@ -33,8 +33,8 @@ var (

type Config struct {
MigrationsTable string
LockTable string
ForceLock bool
LockTable string
ForceLock bool
DatabaseName string
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)}
}

Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -316,7 +316,6 @@ func (c *CockroachDb) ensureVersionTable() error {
return nil
}


func (c *CockroachDb) ensureLockTable() error {
// check if lock table exists
var count int
Expand Down
6 changes: 3 additions & 3 deletions database/cockroachdb/cockroachdb_test.go
Expand Up @@ -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{
Expand All @@ -28,15 +28,15 @@ 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
}
}

_, err = db.Exec("CREATE DATABASE migrate")
return err == nil;
return err == nil

return true
}
Expand Down
10 changes: 5 additions & 5 deletions testing/docker.go
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions testing/testing.go
Expand Up @@ -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:
Expand Down