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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
go-version: "stable"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
Expand Down
29 changes: 23 additions & 6 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
version: "2"
linters:
disable-all: true
default: none
enable:
# Default
- errcheck
- gosimple
- govet
- ineffassign
- misspell
- staticcheck
- testifylint
- unused
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
# Added
- testifylint
- misspell
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ lint: tools

.PHONY: tools
tools:
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
@go install github.com/mfridman/tparse@main

test-packages:
Expand Down
4 changes: 3 additions & 1 deletion examples/go-migrations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ var (
)

func main() {
flags.Parse(os.Args[1:])
if err := flags.Parse(os.Args[1:]); err != nil {
log.Fatalf("goose: failed to parse flags: %v", err)
}
args := flags.Args()

if len(args) < 3 {
Expand Down
4 changes: 2 additions & 2 deletions globals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestNewGoMigration(t *testing.T) {
require.True(t, m.Registered)
require.EqualValues(t, -1, m.Next)
require.EqualValues(t, -1, m.Previous)
require.Equal(t, "", m.Source)
require.Empty(t, m.Source)
require.Nil(t, m.UpFnNoTxContext)
require.Nil(t, m.DownFnNoTxContext)
require.Nil(t, m.UpFnContext)
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestLegacyFunctions(t *testing.T) {
require.True(t, m.Registered)
require.EqualValues(t, -1, m.Next)
require.EqualValues(t, -1, m.Previous)
require.Equal(t, "", m.Source)
require.Empty(t, m.Source)
}

t.Run("all_tx", func(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions lock/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func NewPostgresSessionLocker(opts ...SessionLockerOption) (SessionLocker, error
cfg := sessionLockerConfig{
lockID: DefaultLockID,
lockProbe: probe{
periodSeconds: 5 * time.Second,
intervalDuration: 5 * time.Second,
failureThreshold: 60,
},
unlockProbe: probe{
periodSeconds: 2 * time.Second,
intervalDuration: 2 * time.Second,
failureThreshold: 30,
},
}
Expand All @@ -42,11 +42,11 @@ func NewPostgresSessionLocker(opts ...SessionLockerOption) (SessionLocker, error
lockID: cfg.lockID,
retryLock: retry.WithMaxRetries(
cfg.lockProbe.failureThreshold,
retry.NewConstant(cfg.lockProbe.periodSeconds),
retry.NewConstant(cfg.lockProbe.intervalDuration),
),
retryUnlock: retry.WithMaxRetries(
cfg.unlockProbe.failureThreshold,
retry.NewConstant(cfg.unlockProbe.periodSeconds),
retry.NewConstant(cfg.unlockProbe.intervalDuration),
),
}, nil
}
Expand Down
6 changes: 3 additions & 3 deletions lock/session_locker_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func WithLockTimeout(period, failureThreshold uint64) SessionLockerOption {
return errors.New("failure threshold must be greater than 0, minimum is 1")
}
c.lockProbe = probe{
periodSeconds: time.Duration(period) * time.Second,
intervalDuration: time.Duration(period) * time.Second,
failureThreshold: failureThreshold,
}
return nil
Expand All @@ -67,7 +67,7 @@ func WithUnlockTimeout(period, failureThreshold uint64) SessionLockerOption {
return errors.New("failure threshold must be greater than 0, minimum is 1")
}
c.unlockProbe = probe{
periodSeconds: time.Duration(period) * time.Second,
intervalDuration: time.Duration(period) * time.Second,
failureThreshold: failureThreshold,
}
return nil
Expand All @@ -84,7 +84,7 @@ type sessionLockerConfig struct {
// total timeout will be the period times the failure threshold.
type probe struct {
// How often (in seconds) to perform the probe.
periodSeconds time.Duration
intervalDuration time.Duration
// Number of times to retry the probe.
failureThreshold uint64
}
Expand Down
2 changes: 1 addition & 1 deletion provider_collect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestCollectFileSources(t *testing.T) {
require.NoError(t, err)
got, err := collectFilesystemSources(f, false, nil, nil)
require.NoError(t, err)
require.Equal(t, len(got.sqlSources), len(sqlSources))
require.Len(t, sqlSources, len(got.sqlSources))
require.Empty(t, got.goSources)
for i := 0; i < len(got.sqlSources); i++ {
require.Equal(t, got.sqlSources[i], sqlSources[i])
Expand Down
4 changes: 2 additions & 2 deletions provider_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestProviderRun(t *testing.T) {
// Apply all up migrations
upResult, err := p.Up(ctx)
require.NoError(t, err)
require.Equal(t, len(upResult), len(sources))
require.Len(t, sources, len(upResult))
currentVersion, err := p.GetDBVersion(ctx)
require.NoError(t, err)
require.Equal(t, currentVersion, p.ListSources()[len(sources)-1].Version)
Expand All @@ -207,7 +207,7 @@ func TestProviderRun(t *testing.T) {
// Apply all down migrations
downResult, err := p.DownTo(ctx, 0)
require.NoError(t, err)
require.Equal(t, len(downResult), len(sources))
require.Len(t, sources, len(downResult))
gotVersion, err := getMaxVersionID(db, goose.DefaultTablename)
require.NoError(t, err)
require.EqualValues(t, 0, gotVersion)
Expand Down
2 changes: 1 addition & 1 deletion tests/gomigrations/error/gomigrations_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ func TestGoMigrationByOne(t *testing.T) {
// running within a tx we expect none of the inserts to persist.
err = db.QueryRow("SELECT COUNT(*) FROM foo").Scan(&count)
require.NoError(t, err)
require.EqualValues(t, 0, count)
require.Equal(t, 0, count)

}
Loading