Skip to content

Commit 245d087

Browse files
committed
BUILD/MEDIUM: golang: upgrade go to 1.25 and linter to 2.8.0
1 parent 5424422 commit 245d087

File tree

113 files changed

+739
-735
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+739
-735
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ stages:
88
variables:
99
DOCKER_HOST: tcp://docker:2375
1010
DOCKER_BASE_IMAGE: $CI_REGISTRY_GO/haproxy-debian
11-
BATS_VERSION: v1.4.1
12-
GO_VERSION: "1.24"
11+
BATS_VERSION: v1.10.0
12+
GO_VERSION: "1.25"
1313
DOCKER_VERSION: "26.0"
1414

1515
pipelines-check:

.golangci.yml

Lines changed: 88 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,104 @@
1-
linters-settings:
2-
golint:
3-
min-confidence: 0
4-
gocyclo:
5-
min-complexity: 42
6-
cyclop:
7-
max-complexity: 42
8-
maligned:
9-
suggest-new: true
10-
dupl:
11-
threshold: 200
12-
goconst:
13-
min-len: 2
14-
min-occurrences: 2
15-
revive:
16-
rules:
17-
- name: var-naming
18-
severity: warning
19-
disabled: true
1+
version: "2"
202
linters:
21-
enable-all: true
3+
default: all
224
disable:
5+
- containedctx
6+
- contextcheck
7+
- depguard
238
- dupl
9+
- err113
10+
- errcheck
11+
- errorlint
2412
- exhaustive
13+
- exhaustruct
14+
- forbidigo
15+
- forcetypeassert
16+
- funcorder
2517
- funlen
26-
- gci
2718
- gochecknoglobals
2819
- gocognit
2920
- goconst
21+
- gocritic
3022
- gocyclo
23+
- godoclint
3124
- godot
25+
- godox
26+
- ireturn
3227
- lll
28+
- mnd
29+
- nakedret
3330
- nestif
3431
- nlreturn
35-
- wrapcheck
36-
- wsl
37-
- nakedret
38-
- paralleltest
39-
- testpackage
40-
- varnamelen
41-
- exhaustruct
42-
- nonamedreturns
43-
- forcetypeassert
44-
- rowserrcheck #rowserrcheck is disabled because of generics
45-
- sqlclosecheck #rowserrcheck is disabled because of generics
46-
- wastedassign #rowserrcheck is disabled because of generics
47-
- ireturn
48-
- tagliatelle
4932
- noctx
50-
- errorlint
51-
- contextcheck
52-
- godox
53-
- containedctx
54-
- unused
55-
- unparam
33+
- noinlineerr
34+
- nonamedreturns
35+
- paralleltest
5636
- prealloc
57-
- forbidigo
58-
- errcheck
59-
- gocritic
60-
- tagalign
61-
- depguard
62-
- mnd
63-
- err113
64-
- tenv # deprecated
6537
- recvcheck
66-
67-
issues:
68-
exclude:
69-
# bugs of typecheck linter
70-
- "undeclared name: `shellquote`"
71-
- 'github.com/kballard/go-shellquote" imported but not used'
72-
- 'github.com/haproxytech/client-native/v6/config-parser/types" imported but not used'
73-
exclude-rules:
74-
- linters:
75-
- staticcheck
76-
text: "duplicate struct tag"
77-
- linters:
78-
- gosec
79-
text: "G[501]"
80-
- linters:
81-
- gosec
82-
text: "G[404]"
83-
exclude-dirs:
84-
- test
38+
- rowserrcheck
39+
- sqlclosecheck
40+
- tagalign
41+
- tagliatelle
42+
- testpackage
43+
- unparam
44+
- unused
45+
- varnamelen
46+
- wastedassign
47+
- wrapcheck
48+
- wsl
49+
- wsl_v5
50+
settings:
51+
cyclop:
52+
max-complexity: 42
53+
dupl:
54+
threshold: 200
55+
goconst:
56+
min-len: 2
57+
min-occurrences: 2
58+
gocyclo:
59+
min-complexity: 42
60+
revive:
61+
rules:
62+
- name: var-naming
63+
severity: warning
64+
disabled: true
65+
exclusions:
66+
generated: lax
67+
presets:
68+
- comments
69+
- common-false-positives
70+
- legacy
71+
- std-error-handling
72+
rules:
73+
- linters:
74+
- staticcheck
75+
text: duplicate struct tag
76+
- linters:
77+
- gosec
78+
text: G[501]
79+
- linters:
80+
- gosec
81+
text: G[404]
82+
- path: (.+)\.go$
83+
text: 'undeclared name: `shellquote`'
84+
- path: (.+)\.go$
85+
text: github.com/kballard/go-shellquote" imported but not used
86+
- path: (.+)\.go$
87+
text: github.com/haproxytech/client-native/v6/config-parser/types" imported but not used
88+
paths:
89+
- test
90+
- third_party$
91+
- builtin$
92+
- examples$
93+
formatters:
94+
enable:
95+
- gofmt
96+
- gofumpt
97+
- goimports
98+
exclusions:
99+
generated: lax
100+
paths:
101+
- test
102+
- third_party$
103+
- builtin$
104+
- examples$

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ GIT_MODIFIED=${GIT_MODIFIED1}${GIT_MODIFIED2}
99
SWAGGER_VERSION=${shell curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $$2}'}
1010
BUILD_DATE=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
1111
CGO_ENABLED?=0
12-
GOLANGCI_LINT_VERSION=1.64.5
13-
CHECK_COMMIT=5.0.4
12+
GOLANGCI_LINT_VERSION=2.8.0
13+
CHECK_COMMIT=5.4.0
1414

1515
all: update clean build
1616

adapters/adapters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func RecoverMiddleware(logger *log.Logger) func(h http.Handler) http.Handler {
8585
if err := recover(); err != nil {
8686
frames := callers()
8787

88-
fields := make(map[string]interface{})
88+
fields := make(map[string]any)
8989
fields["stack_trace"] = frames.String()
9090
logger.WithFieldsf(fields, log.ErrorLevel, "Panic %v", err)
9191

client-native/cn.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ func ConfigureConfigurationClient(haproxyOptions dataplaneapi_config.HAProxyConf
4444

4545
p := confClient.Parser()
4646
comments, err := p.Get(parser.Comments, parser.CommentsSectionName, "#")
47-
insertDisclaimer := false
48-
if err != nil {
49-
insertDisclaimer = true
50-
}
47+
insertDisclaimer := err != nil
5148
data, ok := comments.([]types.Comments)
5249
if !ok {
5350
insertDisclaimer = true

cmd/dataplaneapi/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func startServer(cfg *configuration.Configuration, cancelDebugServer context.Can
227227
api.BasicAuthenticator = func(authentication security.UserPassAuthentication) runtime.Authenticator {
228228
// if mTLS is enabled with backing Certificate Authority, skipping basic authentication
229229
if len(server.TLSCACertificate) > 0 && server.TLSPort > 0 {
230-
return runtime.AuthenticatorFunc(func(i interface{}) (bool, interface{}, error) {
230+
return runtime.AuthenticatorFunc(func(i any) (bool, any, error) {
231231
return true, "", nil
232232
})
233233
}

cmd/govulncheck-report/main.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ func main() {
7777

7878
vulnMessage := string(out)
7979
fmt.Println(vulnMessage)
80-
noVuln := false
81-
if !strings.Contains(vulnMessage, "Vulnerability #") {
82-
noVuln = true
83-
}
80+
noVuln := !strings.Contains(vulnMessage, "Vulnerability #")
8481

8582
if currentBranch == "" {
8683
if strings.Contains(vulnMessage, "Vulnerability #") {
@@ -140,7 +137,7 @@ func main() {
140137
func createIssue(baseURL, token, projectID string, title, commentBody string) {
141138
slog.Info("Active issue with title '" + title + "' not found in project " + projectID)
142139
// Create the issue here
143-
issueData := map[string]interface{}{
140+
issueData := map[string]any{
144141
"title": title,
145142
"description": commentBody,
146143
"labels": "bot,critical",
@@ -188,7 +185,7 @@ func closeTheIssue(baseURL, token, projectID string, issueIID int, commentBody s
188185
addCommentToIssue(baseURL, token, projectID, issueIID, commentBody)
189186

190187
client := &http.Client{}
191-
issueData := map[string]interface{}{
188+
issueData := map[string]any{
192189
"state_event": "close",
193190
}
194191
issueDataBytes, err := json.Marshal(issueData)
@@ -230,7 +227,7 @@ func closeTheIssue(baseURL, token, projectID string, issueIID int, commentBody s
230227

231228
func addCommentToIssue(baseURL, token, projectID string, issueIID int, commentBody string) {
232229
client := &http.Client{}
233-
noteData := map[string]interface{}{
230+
noteData := map[string]any{
234231
"body": commentBody,
235232
}
236233
noteDataBytes, err := json.Marshal(noteData)

configuration/bool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (s *AtomicBool) String() string {
4242
return "false"
4343
}
4444

45-
func (s *AtomicBool) UnmarshalYAML(unmarshal func(interface{}) error) error {
45+
func (s *AtomicBool) UnmarshalYAML(unmarshal func(any) error) error {
4646
var buf bool
4747
err := unmarshal(&buf)
4848
if err != nil {
@@ -53,6 +53,6 @@ func (s *AtomicBool) UnmarshalYAML(unmarshal func(interface{}) error) error {
5353
return nil
5454
}
5555

56-
func (s AtomicBool) MarshalYAML() (interface{}, error) {
56+
func (s AtomicBool) MarshalYAML() (any, error) {
5757
return s.Load(), nil
5858
}

configuration/configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (c *Configuration) LoadDataplaneStorageConfig() ([]string, error) {
324324
}
325325

326326
func (c *Configuration) LoadRuntimeVars(swaggerJSON json.RawMessage, host string, port int) error {
327-
var m map[string]interface{}
327+
var m map[string]any
328328
json := jsoniter.ConfigCompatibleWithStandardLibrary
329329
err := json.Unmarshal(swaggerJSON, &m)
330330
if err != nil {

configuration/int.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (s *AtomicInt) String() string {
4040
return strconv.Itoa(s.Load())
4141
}
4242

43-
func (s *AtomicInt) UnmarshalYAML(unmarshal func(interface{}) error) error {
43+
func (s *AtomicInt) UnmarshalYAML(unmarshal func(any) error) error {
4444
var buf int
4545
err := unmarshal(&buf)
4646
if err != nil {
@@ -51,6 +51,6 @@ func (s *AtomicInt) UnmarshalYAML(unmarshal func(interface{}) error) error {
5151
return nil
5252
}
5353

54-
func (s AtomicInt) MarshalYAML() (interface{}, error) {
54+
func (s AtomicInt) MarshalYAML() (any, error) {
5555
return s.Load(), nil
5656
}

0 commit comments

Comments
 (0)