From eb4dfe670086a9a4ac184fc525c4a6135f94fe4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Apr 2025 10:43:10 -0500 Subject: [PATCH] go 1.23 & golangci-lint v2 (#843) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: John Roesler --- .github/workflows/go_test.yml | 6 +-- .golangci.bck.yaml | 42 ++++++++++++++++++++ .golangci.yaml | 73 ++++++++++++++++++++--------------- .pre-commit-config.yaml | 4 +- go.mod | 2 +- scheduler_test.go | 20 ++-------- 6 files changed, 92 insertions(+), 55 deletions(-) create mode 100644 .golangci.bck.yaml diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml index 2aba0d2..042191f 100644 --- a/.github/workflows/go_test.yml +++ b/.github/workflows/go_test.yml @@ -12,8 +12,6 @@ strategy: matrix: go-version: - - "1.21" - - "1.22" - "1.23" - "1.24" name: lint and test @@ -26,8 +24,8 @@ with: go-version: ${{ matrix.go-version }} - name: golangci-lint - uses: golangci/golangci-lint-action@v6.5.0 + uses: golangci/golangci-lint-action@v7.0.0 with: - version: v1.64.5 + version: v2.1.5 - name: test run: make test_ci diff --git a/.golangci.bck.yaml b/.golangci.bck.yaml new file mode 100644 index 0000000..e4f0cc1 --- /dev/null +++ b/.golangci.bck.yaml @@ -0,0 +1,42 @@ +run: + timeout: 5m + issues-exit-code: 1 + tests: true + +issues: + max-same-issues: 100 + include: + - EXC0012 + - EXC0014 + exclude-dirs: + - local + exclude-rules: + - path: example_test.go + linters: + - revive + text: "seems to be unused" + fix: true + +linters: + enable: + - bodyclose + - copyloopvar + - gofumpt + - goimports + - gosimple + - govet + - ineffassign + - misspell + - revive + - staticcheck + - typecheck + - unused + - whitespace + +output: + formats: + - format: colored-line-number + print-issued-lines: true + print-linter-name: true + path-prefix: "" + sort-results: true diff --git a/.golangci.yaml b/.golangci.yaml index e4f0cc1..33ebebf 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,42 +1,51 @@ +version: "2" run: - timeout: 5m issues-exit-code: 1 tests: true - -issues: - max-same-issues: 100 - include: - - EXC0012 - - EXC0014 - exclude-dirs: - - local - exclude-rules: - - path: example_test.go - linters: - - revive - text: "seems to be unused" - fix: true - +output: + formats: + text: + path: stdout + print-linter-name: true + print-issued-lines: true + path-prefix: "" linters: enable: - bodyclose - copyloopvar - - gofumpt - - goimports - - gosimple - - govet - - ineffassign - misspell - revive - - staticcheck - - typecheck - - unused - whitespace - -output: - formats: - - format: colored-line-number - print-issued-lines: true - print-linter-name: true - path-prefix: "" - sort-results: true + exclusions: + generated: lax + presets: + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - revive + path: example_test.go + text: seems to be unused + - linters: + - revive + text: package-comments + paths: + - local + - third_party$ + - builtin$ + - examples$ +issues: + max-same-issues: 100 + fix: true +formatters: + enable: + - gofumpt + - goimports + exclusions: + generated: lax + paths: + - local + - third_party$ + - builtin$ + - examples$ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e57a00..125f461 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/golangci/golangci-lint - rev: v1.64.5 + rev: v2.1.5 hooks: - id: golangci-lint - repo: https://github.com/TekWizely/pre-commit-golang diff --git a/go.mod b/go.mod index 45ddf58..9d544da 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/go-co-op/gocron/v2 -go 1.21.0 +go 1.23.0 require ( github.com/google/uuid v1.6.0 diff --git a/scheduler_test.go b/scheduler_test.go index 9f84562..4ef276d 100644 --- a/scheduler_test.go +++ b/scheduler_test.go @@ -1626,10 +1626,7 @@ func TestScheduler_WithDistributed(t *testing.T) { func(t *testing.T) { timeout := time.Now().Add(1 * time.Second) var notLeaderCount int - for { - if time.Now().After(timeout) { - break - } + for !time.Now().After(timeout) { select { case <-notLeader: notLeaderCount++ @@ -1650,10 +1647,7 @@ func TestScheduler_WithDistributed(t *testing.T) { func(_ *testing.T) { timeout := time.Now().Add(1 * time.Second) var notLockedCount int - for { - if time.Now().After(timeout) { - break - } + for !time.Now().After(timeout) { select { case <-notLocked: notLockedCount++ @@ -1675,10 +1669,7 @@ func TestScheduler_WithDistributed(t *testing.T) { func(_ *testing.T) { timeout := time.Now().Add(1 * time.Second) var notLockedCount int - for { - if time.Now().After(timeout) { - break - } + for !time.Now().After(timeout) { select { case <-notLocked: notLockedCount++ @@ -1702,10 +1693,7 @@ func TestScheduler_WithDistributed(t *testing.T) { func(_ *testing.T) { timeout := time.Now().Add(1 * time.Second) var notLockedCount int - for { - if time.Now().After(timeout) { - break - } + for !time.Now().After(timeout) { select { case <-notLocked: notLockedCount++