Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
with:
go-version: "1.25.x"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: v1.64.8
version: v2.6.2

test:
runs-on: ubuntu-latest
Expand Down
47 changes: 27 additions & 20 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
version: "2"
linters:
enable:
#- golint
#- interfacer
- unconvert
#- dupl
- goconst
- gofmt
- misspell
- unparam
- nakedret
- prealloc
- revive
#- gosec
linters-settings:
misspell:
locale: US
revive:
- unconvert
- unparam
settings:
misspell:
locale: US
revive:
rules:
- name: redundant-build-tag
exclusions:
generated: lax
rules:
- name: redundant-build-tag
- path: (.+)\.go$
text: G104
paths:
- third_party$
- builtin$
- examples$
issues:
max-same-issues: 0
max-issues-per-linter: 0
exclude-use-default: false
exclude:
# gosec: Duplicated errcheck checks
- G104
max-same-issues: 0
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion database/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func parseConsistency(consistencyStr string) (consistency gocql.Consistency, err
var ok bool
err, ok = r.(error)
if !ok {
err = fmt.Errorf("Failed to parse consistency \"%s\": %v", consistencyStr, r)
err = fmt.Errorf("failed to parse consistency \"%s\": %v", consistencyStr, r)
}
}
}()
Expand Down
2 changes: 1 addition & 1 deletion database/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,5 @@ func quoteIdentifier(name string) string {
if end > -1 {
name = name[:end]
}
return `"` + strings.Replace(name, `"`, `""`, -1) + `"`
return `"` + strings.ReplaceAll(name, `"`, `""`) + `"`
}
2 changes: 1 addition & 1 deletion database/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
ErrNilConfig = fmt.Errorf("no config")
ErrNoDatabaseName = fmt.Errorf("no database name")
ErrAppendPEM = fmt.Errorf("failed to append PEM")
ErrTLSCertKeyConfig = fmt.Errorf("To use TLS client authentication, both x-tls-cert and x-tls-key must not be empty")
ErrTLSCertKeyConfig = fmt.Errorf("to use TLS client authentication, both x-tls-cert and x-tls-key must not be empty")
)

type Config struct {
Expand Down
8 changes: 4 additions & 4 deletions database/pgx/pgx.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
if s := purl.Query().Get("x-migrations-table-quoted"); len(s) > 0 {
migrationsTableQuoted, err = strconv.ParseBool(s)
if err != nil {
return nil, fmt.Errorf("Unable to parse option x-migrations-table-quoted: %w", err)
return nil, fmt.Errorf("unable to parse option x-migrations-table-quoted: %w", err)
}
}
if (len(migrationsTable) > 0) && (migrationsTableQuoted) && ((migrationsTable[0] != '"') || (migrationsTable[len(migrationsTable)-1] != '"')) {
Expand Down Expand Up @@ -212,7 +212,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
if s := purl.Query().Get("x-multi-statement"); len(s) > 0 {
multiStatementEnabled, err = strconv.ParseBool(s)
if err != nil {
return nil, fmt.Errorf("Unable to parse option x-multi-statement: %w", err)
return nil, fmt.Errorf("unable to parse option x-multi-statement: %w", err)
}
}

Expand Down Expand Up @@ -412,7 +412,7 @@ func (p *Postgres) runStatement(statement []byte) error {

func computeLineFromPos(s string, pos int) (line uint, col uint, ok bool) {
// replace crlf with lf
s = strings.Replace(s, "\r\n", "\n", -1)
s = strings.ReplaceAll(s, "\r\n", "\n")
// pg docs: pos uses index 1 for the first character, and positions are measured in characters not bytes
runes := []rune(s)
if pos > len(runes) {
Expand Down Expand Up @@ -613,5 +613,5 @@ func quoteIdentifier(name string) string {
if end > -1 {
name = name[:end]
}
return `"` + strings.Replace(name, `"`, `""`, -1) + `"`
return `"` + strings.ReplaceAll(name, `"`, `""`) + `"`
}
4 changes: 2 additions & 2 deletions database/pgx/pgx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,10 +755,10 @@ func Test_computeLineFromPos(t *testing.T) {
t.Run(name, func(t *testing.T) {
input := tc.input
if crlf {
input = strings.Replace(input, "\n", "\r\n", -1)
input = strings.ReplaceAll(input, "\n", "\r\n")
}
if nonASCII {
input = strings.Replace(input, "FROM", "FRÖM", -1)
input = strings.ReplaceAll(input, "FROM", "FRÖM")
}
gotLine, gotCol, gotOK := computeLineFromPos(input, tc.pos)

Expand Down
8 changes: 4 additions & 4 deletions database/pgx/v5/pgx.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
if s := purl.Query().Get("x-migrations-table-quoted"); len(s) > 0 {
migrationsTableQuoted, err = strconv.ParseBool(s)
if err != nil {
return nil, fmt.Errorf("Unable to parse option x-migrations-table-quoted: %w", err)
return nil, fmt.Errorf("unable to parse option x-migrations-table-quoted: %w", err)
}
}
if (len(migrationsTable) > 0) && (migrationsTableQuoted) && ((migrationsTable[0] != '"') || (migrationsTable[len(migrationsTable)-1] != '"')) {
Expand Down Expand Up @@ -188,7 +188,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
if s := purl.Query().Get("x-multi-statement"); len(s) > 0 {
multiStatementEnabled, err = strconv.ParseBool(s)
if err != nil {
return nil, fmt.Errorf("Unable to parse option x-multi-statement: %w", err)
return nil, fmt.Errorf("unable to parse option x-multi-statement: %w", err)
}
}

Expand Down Expand Up @@ -303,7 +303,7 @@ func (p *Postgres) runStatement(statement []byte) error {

func computeLineFromPos(s string, pos int) (line uint, col uint, ok bool) {
// replace crlf with lf
s = strings.Replace(s, "\r\n", "\n", -1)
s = strings.ReplaceAll(s, "\r\n", "\n")
// pg docs: pos uses index 1 for the first character, and positions are measured in characters not bytes
runes := []rune(s)
if pos > len(runes) {
Expand Down Expand Up @@ -476,5 +476,5 @@ func quoteIdentifier(name string) string {
if end > -1 {
name = name[:end]
}
return `"` + strings.Replace(name, `"`, `""`, -1) + `"`
return `"` + strings.ReplaceAll(name, `"`, `""`) + `"`
}
4 changes: 2 additions & 2 deletions database/pgx/v5/pgx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,10 @@ func Test_computeLineFromPos(t *testing.T) {
t.Run(name, func(t *testing.T) {
input := tc.input
if crlf {
input = strings.Replace(input, "\n", "\r\n", -1)
input = strings.ReplaceAll(input, "\n", "\r\n")
}
if nonASCII {
input = strings.Replace(input, "FROM", "FRÖM", -1)
input = strings.ReplaceAll(input, "FROM", "FRÖM")
}
gotLine, gotCol, gotOK := computeLineFromPos(input, tc.pos)

Expand Down
6 changes: 3 additions & 3 deletions database/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
if s := purl.Query().Get("x-migrations-table-quoted"); len(s) > 0 {
migrationsTableQuoted, err = strconv.ParseBool(s)
if err != nil {
return nil, fmt.Errorf("Unable to parse option x-migrations-table-quoted: %w", err)
return nil, fmt.Errorf("unable to parse option x-migrations-table-quoted: %w", err)
}
}
if (len(migrationsTable) > 0) && (migrationsTableQuoted) && ((migrationsTable[0] != '"') || (migrationsTable[len(migrationsTable)-1] != '"')) {
Expand Down Expand Up @@ -196,7 +196,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
if s := purl.Query().Get("x-multi-statement"); len(s) > 0 {
multiStatementEnabled, err = strconv.ParseBool(s)
if err != nil {
return nil, fmt.Errorf("Unable to parse option x-multi-statement: %w", err)
return nil, fmt.Errorf("unable to parse option x-multi-statement: %w", err)
}
}

Expand Down Expand Up @@ -319,7 +319,7 @@ func (p *Postgres) runStatement(statement []byte) error {

func computeLineFromPos(s string, pos int) (line uint, col uint, ok bool) {
// replace crlf with lf
s = strings.Replace(s, "\r\n", "\n", -1)
s = strings.ReplaceAll(s, "\r\n", "\n")
// pg docs: pos uses index 1 for the first character, and positions are measured in characters not bytes
runes := []rune(s)
if pos > len(runes) {
Expand Down
4 changes: 2 additions & 2 deletions database/postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,10 +798,10 @@ func Test_computeLineFromPos(t *testing.T) {
t.Run(name, func(t *testing.T) {
input := tc.input
if crlf {
input = strings.Replace(input, "\n", "\r\n", -1)
input = strings.ReplaceAll(input, "\n", "\r\n")
}
if nonASCII {
input = strings.Replace(input, "FROM", "FRÖM", -1)
input = strings.ReplaceAll(input, "FROM", "FRÖM")
}
gotLine, gotCol, gotOK := computeLineFromPos(input, tc.pos)

Expand Down
2 changes: 1 addition & 1 deletion database/redshift/redshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (p *Redshift) Run(migration io.Reader) error {

func computeLineFromPos(s string, pos int) (line uint, col uint, ok bool) {
// replace crlf with lf
s = strings.Replace(s, "\r\n", "\n", -1)
s = strings.ReplaceAll(s, "\r\n", "\n")
// pg docs: pos uses index 1 for the first character, and positions are measured in characters not bytes
runes := []rune(s)
if pos > len(runes) {
Expand Down
4 changes: 2 additions & 2 deletions database/redshift/redshift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,10 @@ func Test_computeLineFromPos(t *testing.T) {
t.Run(name, func(t *testing.T) {
input := tc.input
if crlf {
input = strings.Replace(input, "\n", "\r\n", -1)
input = strings.ReplaceAll(input, "\n", "\r\n")
}
if nonASCII {
input = strings.Replace(input, "FROM", "FRÖM", -1)
input = strings.ReplaceAll(input, "FROM", "FRÖM")
}
gotLine, gotCol, gotOK := computeLineFromPos(input, tc.pos)

Expand Down
2 changes: 1 addition & 1 deletion database/snowflake/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (p *Snowflake) Run(migration io.Reader) error {

func computeLineFromPos(s string, pos int) (line uint, col uint, ok bool) {
// replace crlf with lf
s = strings.Replace(s, "\r\n", "\n", -1)
s = strings.ReplaceAll(s, "\r\n", "\n")
// pg docs: pos uses index 1 for the first character, and positions are measured in characters not bytes
runes := []rune(s)
if pos > len(runes) {
Expand Down
2 changes: 1 addition & 1 deletion database/sqlserver/sqlserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
ErrNoDatabaseName = fmt.Errorf("no database name")
ErrNoSchema = fmt.Errorf("no schema")
ErrDatabaseDirty = fmt.Errorf("database is dirty")
ErrMultipleAuthOptionsPassed = fmt.Errorf("both password and useMsi=true were passed.")
ErrMultipleAuthOptionsPassed = fmt.Errorf("both password and useMsi=true were passed")
)

var lockErrorMap = map[int]string{
Expand Down
2 changes: 1 addition & 1 deletion database/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestLockAndUnlock(t *testing.T, d database.Driver) {
case <-done:
return
case <-timeout:
errs <- fmt.Errorf("Timeout after 15 seconds. Looks like a deadlock in Lock/UnLock.\n%#v", d)
errs <- fmt.Errorf("timeout after 15 seconds. Looks like a deadlock in Lock/UnLock\n%#v", d)
return
}
}
Expand Down
10 changes: 5 additions & 5 deletions internal/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
)

var (
errInvalidSequenceWidth = errors.New("Digits must be positive")
errIncompatibleSeqAndFormat = errors.New("The seq and format options are mutually exclusive")
errInvalidTimeFormat = errors.New("Time format may not be empty")
errInvalidSequenceWidth = errors.New("digits must be positive")
errIncompatibleSeqAndFormat = errors.New("the seq and format options are mutually exclusive")
errInvalidTimeFormat = errors.New("time format may not be empty")
)

func nextSeqVersion(matches []string, seqDigits int) (string, error) {
Expand All @@ -33,7 +33,7 @@ func nextSeqVersion(matches []string, seqDigits int) (string, error) {
idx := strings.Index(matchSeqStr, "_")

if idx < 1 { // Using 1 instead of 0 since there should be at least 1 digit
return "", fmt.Errorf("Malformed migration filename: %s", filename)
return "", fmt.Errorf("malformed migration filename: %s", filename)
}

var err error
Expand All @@ -50,7 +50,7 @@ func nextSeqVersion(matches []string, seqDigits int) (string, error) {
version := fmt.Sprintf("%0[2]*[1]d", nextSeq, seqDigits)

if len(version) > seqDigits {
return "", fmt.Errorf("Next sequence number %s too large. At most %d digits are allowed", version, seqDigits)
return "", fmt.Errorf("next sequence number %s too large, at most %d digits are allowed", version, seqDigits)
}

return version, nil
Expand Down
2 changes: 1 addition & 1 deletion source/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (g *Gitlab) readDirectory() error {
if response.CurrentPage >= response.TotalPages {
break
}
g.listOptions.ListOptions.Page = response.NextPage
g.listOptions.Page = response.NextPage
}

for i := range nodes {
Expand Down
10 changes: 5 additions & 5 deletions testing/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type DockerContainer struct {

func (d *DockerContainer) PullImage() (err error) {
if d == nil {
return errors.New("Cannot pull image on a nil *DockerContainer")
return errors.New("cannot pull image on a nil *DockerContainer")
}
d.t.Logf("Docker: Pull image %v", d.ImageName)
r, err := d.client.ImagePull(context.Background(), d.ImageName, dockerimage.PullOptions{})
Expand Down Expand Up @@ -98,7 +98,7 @@ func (d *DockerContainer) PullImage() (err error) {

func (d *DockerContainer) Start() error {
if d == nil {
return errors.New("Cannot start a nil *DockerContainer")
return errors.New("cannot start a nil *DockerContainer")
}

containerName := fmt.Sprintf("migrate_test_%s", pseudoRandStr(10))
Expand Down Expand Up @@ -146,7 +146,7 @@ func (d *DockerContainer) KeepForDebugging() {

func (d *DockerContainer) Remove() error {
if d == nil {
return errors.New("Cannot remove a nil *DockerContainer")
return errors.New("cannot remove a nil *DockerContainer")
}

if d.keepForDebugging {
Expand All @@ -169,7 +169,7 @@ func (d *DockerContainer) Remove() error {

func (d *DockerContainer) Inspect() error {
if d == nil {
return errors.New("Cannot inspect a nil *DockerContainer")
return errors.New("cannot inspect a nil *DockerContainer")
}

if len(d.ContainerId) == 0 {
Expand All @@ -187,7 +187,7 @@ func (d *DockerContainer) Inspect() error {

func (d *DockerContainer) Logs() (io.ReadCloser, error) {
if d == nil {
return nil, errors.New("Cannot view logs for a nil *DockerContainer")
return nil, errors.New("cannot view logs for a nil *DockerContainer")
}
if len(d.ContainerId) == 0 {
return nil, errors.New("missing containerId")
Expand Down
Loading