diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f26c51b..ce46d26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,6 @@ jobs: go build -race - name: golangci-lint - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v9 with: - version: latest + version: v2.12.2 diff --git a/.golangci.yml b/.golangci.yml index 5d0a4b6..bf573b7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,33 +1,40 @@ +version: "2" linters: + default: none enable: - - revive - - govet - - unconvert - - megacheck - - gas - - gocyclo - dupl - - misspell - - unparam - - unused - - typecheck - - ineffassign - - stylecheck - gochecknoinits - - exportloopref - gocritic + - gocyclo + - gosec + - govet + - ineffassign + - misspell - nakedret - - gosimple - prealloc - fast: false - disable-all: true - -issues: - exclude-rules: - - path: _test\.go - linters: - - dupl - - text: "Errors unhandled" - linters: - - gosec - exclude-use-default: false + - revive + - staticcheck + - unconvert + - unparam + - unused + exclusions: + generated: lax + rules: + - linters: + - dupl + path: _test\.go + - linters: + - gosec + text: Errors unhandled + paths: + - internal/time/rate + - third_party$ + - builtin$ + - examples$ +formatters: + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/limiter/limiter_options.go b/limiter/limiter_options.go index e5f537b..7629f47 100644 --- a/limiter/limiter_options.go +++ b/limiter/limiter_options.go @@ -9,6 +9,7 @@ type ExpirableOptions struct { DefaultExpirationTTL time.Duration // How frequently expire job triggers + // // Deprecated: not used anymore ExpireJobInterval time.Duration } diff --git a/tollbooth.go b/tollbooth.go index 493b2ca..426527f 100644 --- a/tollbooth.go +++ b/tollbooth.go @@ -197,7 +197,7 @@ func BuildKeys(lmt *limiter.Limiter, r *http.Request) [][]string { remoteIP := libstring.RemoteIPFromIPLookup(lmt.GetIPLookup(), r) remoteIP = libstring.CanonicalizeIP(remoteIP) path := r.URL.Path - sliceKeys := make([][]string, 0) + sliceKeys := make([][]string, 0, 1) lmtMethods := lmt.GetMethods() lmtHeaders := lmt.GetHeaders()