Skip to content

Commit 54be657

Browse files
committed
chore: update linter, dependencies, and CI
1 parent 7642dfc commit 54be657

File tree

17 files changed

+78
-85
lines changed

17 files changed

+78
-85
lines changed

.github/workflows/go-cross.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ name: Go Matrix
33
on:
44
push:
55
branches:
6+
- main
67
- master
78
pull_request:
9+
branches:
10+
- main
11+
- master
812

913
jobs:
1014

@@ -22,13 +26,8 @@ jobs:
2226
# os: [ubuntu-latest, macos-latest, windows-latest]
2327

2428
steps:
25-
# https://github.com/marketplace/actions/checkout
26-
- name: Checkout code
27-
uses: actions/checkout@v4
28-
29-
# https://github.com/marketplace/actions/setup-go-environment
30-
- name: Set up Go ${{ matrix.go-version }}
31-
uses: actions/setup-go@v5
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-go@v5
3231
with:
3332
go-version: ${{ matrix.go-version }}
3433

.github/workflows/pr.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
name: Main
22

33
on:
4+
push:
5+
branches:
6+
- main
7+
- master
48
pull_request:
9+
branches:
10+
- main
11+
- master
512

613
jobs:
714

@@ -10,20 +17,11 @@ jobs:
1017
runs-on: ubuntu-latest
1118
env:
1219
GO_VERSION: stable
13-
GOLANGCI_LINT_VERSION: v1.57.2
20+
GOLANGCI_LINT_VERSION: v1.59.1
1421

1522
steps:
16-
17-
# https://github.com/marketplace/actions/checkout
18-
- name: Check out code
19-
uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 0
22-
23-
24-
# https://github.com/marketplace/actions/setup-go-environment
25-
- name: Set up Go ${{ env.GO_VERSION }}
26-
uses: actions/setup-go@v5
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-go@v5
2725
with:
2826
go-version: ${{ env.GO_VERSION }}
2927

.golangci.yml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,33 @@ linters-settings:
4949
testifylint:
5050
disable:
5151
- go-require
52+
perfsprint:
53+
err-error: true
54+
errorf: true
55+
sprintf1: true
56+
strconcat: false
5257

5358
linters:
5459
enable-all: true
5560
disable:
56-
- deadcode # deprecated
57-
- exhaustivestruct # deprecated
58-
- golint # deprecated
59-
- ifshort # deprecated
60-
- interfacer # deprecated
61-
- maligned # deprecated
62-
- nosnakecase # deprecated
63-
- scopelint # deprecated
64-
- structcheck # deprecated
65-
- varcheck # deprecated
61+
- gomnd # deprecated
62+
- execinquery # deprecated
6663
- sqlclosecheck # not relevant (SQL)
6764
- rowserrcheck # not relevant (SQL)
68-
- execinquery # not relevant (SQL)
6965
- cyclop # duplicate of gocyclo
7066
- lll
7167
- dupl
7268
- wsl
7369
- nlreturn
74-
- gomnd
75-
- goerr113
70+
- mnd
71+
- err113
7672
- wrapcheck
7773
- exhaustive
7874
- exhaustruct
7975
- testpackage
8076
- tparallel
8177
- paralleltest
8278
- prealloc
83-
- ifshort
8479
- forcetypeassert
8580
- bodyclose # Too many false positives: https://github.com/timakin/bodyclose/issues/30
8681
- varnamelen
@@ -92,9 +87,6 @@ linters:
9287
- gochecknoglobals # TODO(ldez) should be use on the project
9388
- nestif # TODO(ldez) should be use on the project
9489
- musttag
95-
- perfsprint # TODO(ldez) should be use on the project
96-
- copyloopvar # TODO(ldez) should be use on the project (only for go>=1.22)
97-
- intrange # TODO(ldez) should be use on the project (only for go>=1.22)
9890

9991
output:
10092
show-stats: true
@@ -115,14 +107,14 @@ issues:
115107
- 'Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked'
116108
- 'SA1019: http.CloseNotifier has been deprecated'
117109
- 'exported: func name will be used as roundrobin.RoundRobinRequestRewriteListener by other packages'# TODO(ldez) must be fixed
118-
- 'G101: Potential hardcoded credentials' # TODO(ldez) https://github.com/golangci/golangci-lint/issues/4037
119110

120111
exclude-rules:
121112
- path: .*_test.go
122113
linters:
123114
- funlen
124115
- gosec
125116
- goconst
117+
- canonicalheader
126118
- path: testutils/.+
127119
linters:
128120
- gosec

cbreaker/cbreaker_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cbreaker
22

33
import (
4+
"errors"
45
"fmt"
56
"io"
67
"net/http"
@@ -115,7 +116,7 @@ func TestRedirectWithPath(t *testing.T) {
115116

116117
client := &http.Client{
117118
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
118-
return fmt.Errorf("no redirects")
119+
return errors.New("no redirects")
119120
},
120121
}
121122

@@ -145,7 +146,7 @@ func TestRedirect(t *testing.T) {
145146

146147
client := &http.Client{
147148
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
148-
return fmt.Errorf("no redirects")
149+
return errors.New("no redirects")
149150
},
150151
}
151152

cbreaker/effect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cbreaker
22

33
import (
44
"bytes"
5-
"fmt"
5+
"errors"
66
"io"
77
"net/http"
88
"net/url"
@@ -35,7 +35,7 @@ type WebhookSideEffect struct {
3535
// NewWebhookSideEffectsWithLogger creates a new WebhookSideEffect.
3636
func NewWebhookSideEffectsWithLogger(w Webhook, l utils.Logger) (*WebhookSideEffect, error) {
3737
if w.Method == "" {
38-
return nil, fmt.Errorf("supply method")
38+
return nil, errors.New("supply method")
3939
}
4040
_, err := url.Parse(w.URL)
4141
if err != nil {

connlimit/connlimit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package connlimit
33

44
import (
5+
"errors"
56
"fmt"
67
"net/http"
78
"sync"
@@ -28,7 +29,7 @@ type ConnLimiter struct {
2829
// New creates a new ConnLimiter.
2930
func New(next http.Handler, extract utils.SourceExtractor, maxConnections int64, options ...Option) (*ConnLimiter, error) {
3031
if extract == nil {
31-
return nil, fmt.Errorf("extract function can not be nil")
32+
return nil, errors.New("extract function can not be nil")
3233
}
3334

3435
cl := &ConnLimiter{

connlimit/connlimit_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package connlimit
22

33
import (
4-
"fmt"
4+
"errors"
55
"net/http"
66
"net/http/httptest"
77
"testing"
@@ -104,7 +104,7 @@ func headerLimiter(req *http.Request) (string, int64, error) {
104104
}
105105

106106
func faultyExtractor(_ *http.Request) (string, int64, error) {
107-
return "", -1, fmt.Errorf("oops")
107+
return "", -1, errors.New("oops")
108108
}
109109

110110
var headerLimit = utils.ExtractorFunc(headerLimiter)

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ go 1.19
44

55
require (
66
github.com/HdrHistogram/hdrhistogram-go v1.1.2
7-
github.com/gorilla/websocket v1.5.1
7+
github.com/gorilla/websocket v1.5.3
88
github.com/mailgun/multibuf v0.1.2
99
github.com/segmentio/fasthash v1.0.3
1010
github.com/stretchr/testify v1.9.0
1111
github.com/vulcand/predicate v1.2.0
12-
golang.org/x/net v0.24.0
12+
golang.org/x/net v0.26.0
1313
)
1414

1515
require (
@@ -18,8 +18,8 @@ require (
1818
github.com/jonboulle/clockwork v0.4.0 // indirect
1919
github.com/pmezard/go-difflib v1.0.0 // indirect
2020
github.com/sirupsen/logrus v1.9.3 // indirect
21-
golang.org/x/crypto v0.22.0 // indirect
22-
golang.org/x/sys v0.19.0 // indirect
23-
golang.org/x/term v0.19.0 // indirect
21+
golang.org/x/crypto v0.24.0 // indirect
22+
golang.org/x/sys v0.21.0 // indirect
23+
golang.org/x/term v0.21.0 // indirect
2424
gopkg.in/yaml.v3 v3.0.1 // indirect
2525
)

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
2323
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
2424
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
2525
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
26-
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
27-
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
26+
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
27+
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
2828
github.com/gravitational/trace v1.1.16-0.20220114165159-14a9a7dd6aaf h1:C1GPyPJrOlJlIrcaBBiBpDsqZena2Ks8spa5xZqr1XQ=
2929
github.com/gravitational/trace v1.1.16-0.20220114165159-14a9a7dd6aaf/go.mod h1:zXqxTI6jXDdKnlf8s+nT+3c8LrwUEy3yNpO4XJL90lA=
3030
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
@@ -59,8 +59,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
5959
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
6060
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
6161
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
62-
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
63-
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
62+
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
63+
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
6464
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
6565
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
6666
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -83,8 +83,8 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
8383
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
8484
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
8585
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
86-
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
87-
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
86+
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
87+
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
8888
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
8989
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
9090
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -96,10 +96,10 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
9696
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
9797
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
9898
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
99-
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
100-
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
101-
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
102-
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
99+
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
100+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
101+
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
102+
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
103103
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
104104
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
105105
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

memmetrics/counter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package memmetrics
22

33
import (
4-
"fmt"
4+
"errors"
55
"time"
66

77
"github.com/vulcand/oxy/v2/internal/holsterv4/clock"
@@ -23,10 +23,10 @@ type RollingCounter struct {
2323
// By default, creates a bucket with 10 buckets and 1 second resolution.
2424
func NewCounter(buckets int, resolution time.Duration, options ...rcOption) (*RollingCounter, error) {
2525
if buckets <= 0 {
26-
return nil, fmt.Errorf("buckets should be >= 0")
26+
return nil, errors.New("buckets should be >= 0")
2727
}
2828
if resolution < clock.Second {
29-
return nil, fmt.Errorf("resolution should be larger than a second")
29+
return nil, errors.New("resolution should be larger than a second")
3030
}
3131

3232
rc := &RollingCounter{

0 commit comments

Comments
 (0)