Skip to content

Commit 4747884

Browse files
authored
build(go, deps): switch to Go 1.24 linter 2.4.0 and update modules (hybridgroup#1162)
1 parent 8cea8a6 commit 4747884

File tree

206 files changed

+718
-616
lines changed

Some content is hidden

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

206 files changed

+718
-616
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ version: 2
1414
jobs:
1515
"test_core_and_drivers_with_coverage":
1616
docker:
17-
- image: cimg/go:1.22
17+
- image: cimg/go:1.24
1818
steps:
1919
- checkout
2020
- run:
@@ -31,7 +31,7 @@ jobs:
3131
3232
"test_platforms":
3333
docker:
34-
- image: cimg/go:1.22
34+
- image: cimg/go:1.24
3535
steps:
3636
- checkout
3737
- run:
@@ -45,7 +45,7 @@ jobs:
4545
4646
"check_examples":
4747
docker:
48-
- image: cimg/go:1.22
48+
- image: cimg/go:1.24
4949
steps:
5050
- checkout
5151
- run:
@@ -61,7 +61,7 @@ jobs:
6161
6262
"fmt_check_examples":
6363
docker:
64-
- image: golangci/golangci-lint:v1.64.5
64+
- image: golangci/golangci-lint:v2.4.0
6565
steps:
6666
- checkout
6767
- run:

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ If this is a new driver or adaptor:
2222
- [ ] I have added an example to see how to setup and use it
2323
- [ ] I have checked or build at least my new example (e.g. by run `make examples_check`)
2424

25-
If this is a Go version update:
25+
If this is a Go version or module update:
2626

2727
- [ ] go.mod to new version updated
2828
- [ ] modules updated (go get -u -t ./...)

.github/workflows/golangci-lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ jobs:
1515
name: lint
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
1919
- uses: actions/setup-go@v5
2020
with:
21-
go-version: '1.22'
21+
go-version: '1.24'
2222
cache: false
2323
- name: golangci-lint
24-
uses: golangci/golangci-lint-action@v6
24+
uses: golangci/golangci-lint-action@v7
2525
with:
2626
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
27-
version: v1.64.5
27+
version: v2.4.0
2828

2929
# Optional: working directory, useful for monorepos
3030
# working-directory: v2

.golangci.yml

Lines changed: 106 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# note: GolangCI-Lint also searches for config files in all directories from the directory of the first analyzed path up to the root.
2+
version: "2"
23
run:
34
build-tags:
45
- utils
@@ -22,22 +23,12 @@ run:
2223
# By default, it isn't set.
2324
modules-download-mode: readonly
2425

25-
issues:
26-
# Enables skipping of directories:
27-
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
28-
# Default: true
29-
exclude-dirs-use-default: false
30-
31-
# note: folders/files can not be excluded from "typecheck" anymore since v1.61.0
32-
33-
linters:
34-
enable-all: true
35-
3626
# https://golangci-lint.run/usage/linters/#enabled-by-default
3727
# note: typecheck can not be disabled, it is used to check code compilation
28+
linters:
29+
default: all
3830
disable:
39-
# deprecated:
40-
- tenv # replaced by usetesting
31+
# deprecated: none
4132
# not used for this go version: none
4233
# not used for any reason
4334
- err113 # not used (we allow error creation at return statement)
@@ -51,6 +42,7 @@ linters:
5142
- importas # not needed (there is no alias rule at the moment)
5243
- ireturn # not used (we allow return interfaces)
5344
- loggercheck # not needed (relates to kitlog, klog, logr, zap)
45+
- noinlineerr # this violates best practices in other style guides
5446
- paralleltest # not used
5547
- promlinter # not needed (prometheus metrics naming)
5648
- rowserrcheck # not needed (sql related)
@@ -63,6 +55,7 @@ linters:
6355
- dupl # useful with some tweeks (reduce bugs and lines of code)
6456
- errname # useful for common style
6557
- exhaustruct # useful with some exclusions for existing code (e.g. mavlink/common/common.go)
58+
- funcorder # common style, but too many findings
6659
- funlen # useful with some tweeks (reduce bugs, simplify code, better understandable code)
6760
- gocognit # useful with some tweeks (better understandable code)
6861
- goconst # useful (reduce bugs)
@@ -74,95 +67,115 @@ linters:
7467
- mnd # useful with some exclusions for existing code (e.g. mavlink.go)
7568
- nestif # useful (reduce bugs, simplify code, better understandable code)
7669
- nlreturn # more common style, but could become annoying
77-
- stylecheck # useful with some tweaking (e.g. underscores in names should be allowed - we use it for constants retrieved from C/C++)
7870
- tagliatelle # maybe useful with some tweaking or excluding
7971
- varnamelen # maybe useful with some tweaking, but many findings
8072
- whitespace # more common style, but could become annoying
8173
- wsl # more common style, but could become annoying
74+
- wsl_v5 # same as above
75+
76+
exclusions:
77+
generated: lax
78+
presets:
79+
- comments
80+
- common-false-positives
81+
- legacy
82+
- std-error-handling
83+
84+
settings:
85+
depguard:
86+
# Rules to apply.
87+
#
88+
# Variables:
89+
# - File Variables
90+
# you can still use and exclamation mark ! in front of a variable to say not to use it.
91+
# Example !$test will match any file that is not a go test file.
92+
#
93+
# `$all` - matches all go files
94+
# `$test` - matches all go test files
95+
#
96+
# - Package Variables
97+
#
98+
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
99+
#
100+
# Default: Only allow $gostd in all files.
101+
rules:
102+
main:
103+
# Packages that are not allowed where the value is a suggestion.
104+
deny:
105+
- pkg: github.com/pkg/errors
106+
desc: Should be replaced by standard lib errors package
107+
108+
dupword:
109+
# Keywords for detecting duplicate words.
110+
# If this list is not empty, only the words defined in this list will be detected.
111+
# Default: []
112+
keywords:
113+
- the
114+
- and
115+
- a
116+
117+
errorlint:
118+
# Default: true
119+
# %v should be used by default over %w, see https://github.com/uber-go/guide/blob/master/style.md#error-wrapping
120+
errorf: false
121+
# Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true)
122+
# Default: true
123+
errorf-multi: false
82124

83-
linters-settings:
84-
depguard:
85-
# Rules to apply.
86-
#
87-
# Variables:
88-
# - File Variables
89-
# you can still use and exclamation mark ! in front of a variable to say not to use it.
90-
# Example !$test will match any file that is not a go test file.
91-
#
92-
# `$all` - matches all go files
93-
# `$test` - matches all go test files
94-
#
95-
# - Package Variables
96-
#
97-
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
98-
#
99-
# Default: Only allow $gostd in all files.
100-
rules:
101-
main:
102-
# Packages that are not allowed where the value is a suggestion.
103-
deny:
104-
- pkg: "github.com/pkg/errors"
105-
desc: Should be replaced by standard lib errors package
125+
gocritic:
126+
disabled-checks:
127+
- assignOp # very opinionated
128+
- appendAssign # mostly used by intention
106129

107-
dupword:
108-
# Keywords for detecting duplicate words.
109-
# If this list is not empty, only the words defined in this list will be detected.
110-
# Default: []
111-
keywords:
112-
- "the"
113-
- "and"
114-
- "a"
130+
nolintlint:
131+
# Enable to require an explanation of nonzero length after each nolint directive.
132+
# Default: false
133+
require-explanation: true
134+
# Enable to require nolint directives to mention the specific linter being suppressed.
135+
# Default: false
136+
require-specific: true
115137

116-
errorlint:
117-
# Default: true
118-
# %v should be used by default over %w, see https://github.com/uber-go/guide/blob/master/style.md#error-wrapping
119-
errorf: false
120-
# Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true)
121-
# Default: true
122-
errorf-multi: false
138+
perfsprint:
139+
# Optimizes `fmt.Errorf`.
140+
# Default: true
141+
errorf: false
142+
# Optimizes `fmt.Sprintf` with only one argument
143+
# Default: true
144+
sprintf1: false
123145

124-
gci:
125-
# Section configuration to compare against.
126-
# Section names are case-insensitive and may contain parameters in ().
127-
# The default order of sections is `standard > default > custom > blank > dot`,
128-
# If `custom-order` is `true`, it follows the order of `sections` option.
129-
# Default: ["standard", "default"]
130-
sections:
131-
- standard # Standard section: captures all standard packages.
132-
- default # Default section: contains all imports that could not be matched to another section type.
133-
- prefix(gobot.io/x/gobot/) # Custom section: groups all imports with the specified Prefix.
134-
#- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
135-
#- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
136-
# Enable custom order of sections.
137-
# If `true`, make the section order the same as the order of `sections`.
138-
# Default: false
139-
custom-order: true
146+
revive:
147+
rules:
148+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
149+
# disable this rule, because sometimes it has its justification
150+
- name: unexported-return
151+
severity: warning
152+
disabled: true
140153

141-
gocritic:
142-
disabled-checks:
143-
- assignOp # very opinionated
144-
- appendAssign # mostly used by intention
145154

146-
nolintlint:
147-
# Enable to require an explanation of nonzero length after each nolint directive.
148-
# Default: false
149-
require-explanation: true
150-
# Enable to require nolint directives to mention the specific linter being suppressed.
151-
# Default: false
152-
require-specific: true
155+
formatters:
156+
enable:
157+
- gci
158+
- gofmt
159+
- gofumpt
160+
- goimports
153161

154-
perfsprint:
155-
# Optimizes `fmt.Errorf`.
156-
# Default: true
157-
errorf: false
158-
# Optimizes `fmt.Sprintf` with only one argument
159-
# Default: true
160-
sprintf1: false
162+
exclusions:
163+
generated: lax
161164

162-
revive:
163-
rules:
164-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
165-
# disable this rule, because sometimes it has its justification
166-
- name: unexported-return
167-
severity: warning
168-
disabled: true
165+
settings:
166+
gci:
167+
# Section configuration to compare against.
168+
# Section names are case-insensitive and may contain parameters in ().
169+
# The default order of sections is `standard > default > custom > blank > dot`,
170+
# If `custom-order` is `true`, it follows the order of `sections` option.
171+
# Default: ["standard", "default"]
172+
sections:
173+
- standard # Standard section: captures all standard packages.
174+
- default # Default section: contains all imports that could not be matched to another section type.
175+
- prefix(gobot.io/x/gobot/) # Custom section: groups all imports with the specified Prefix.
176+
#- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
177+
#- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
178+
# Enable custom order of sections.
179+
# If `true`, make the section order the same as the order of `sections`.
180+
# Default: false
181+
custom-order: true

api/api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,21 +413,21 @@ func (a *API) jsonRobotFor(name string) (*gobot.JSONRobot, error) {
413413
if robot := a.manager.Robot(name); robot != nil {
414414
return gobot.NewJSONRobot(robot), nil
415415
}
416-
return nil, fmt.Errorf("No Robot found with the name %s", name)
416+
return nil, fmt.Errorf("no Robot found with the name %s", name)
417417
}
418418

419419
func (a *API) jsonDeviceFor(robot string, name string) (*gobot.JSONDevice, error) {
420420
if device := a.manager.Robot(robot).Device(name); device != nil {
421421
return gobot.NewJSONDevice(device), nil
422422
}
423423

424-
return nil, fmt.Errorf("No Device found with the name %s", name)
424+
return nil, fmt.Errorf("no Device found with the name %s", name)
425425
}
426426

427427
func (a *API) jsonConnectionFor(robot string, name string) (*gobot.JSONConnection, error) {
428428
if connection := a.manager.Robot(robot).Connection(name); connection != nil {
429429
return gobot.NewJSONConnection(connection), nil
430430
}
431431

432-
return nil, fmt.Errorf("No Connection found with the name %s", name)
432+
return nil, fmt.Errorf("no Connection found with the name %s", name)
433433
}

api/api_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func TestRobot(t *testing.T) {
166166
a.ServeHTTP(response, request)
167167

168168
_ = json.NewDecoder(response.Body).Decode(&body)
169-
assert.Equal(t, "No Robot found with the name UnknownRobot1", body["error"])
169+
assert.Equal(t, "no Robot found with the name UnknownRobot1", body["error"])
170170
}
171171

172172
func TestRobotDevices(t *testing.T) {
@@ -206,7 +206,7 @@ func TestRobotCommands(t *testing.T) {
206206
a.ServeHTTP(response, request)
207207

208208
_ = json.NewDecoder(response.Body).Decode(&body)
209-
assert.Equal(t, "No Robot found with the name UnknownRobot1", body["error"])
209+
assert.Equal(t, "no Robot found with the name UnknownRobot1", body["error"])
210210
}
211211

212212
func TestExecuteRobotCommand(t *testing.T) {
@@ -245,7 +245,7 @@ func TestExecuteRobotCommand(t *testing.T) {
245245
a.ServeHTTP(response, request)
246246

247247
_ = json.NewDecoder(response.Body).Decode(&body)
248-
assert.Equal(t, "No Robot found with the name UnknownRobot1", body.(map[string]interface{})["error"])
248+
assert.Equal(t, "no Robot found with the name UnknownRobot1", body.(map[string]interface{})["error"])
249249
}
250250

251251
func TestRobotDevice(t *testing.T) {
@@ -269,7 +269,7 @@ func TestRobotDevice(t *testing.T) {
269269
a.ServeHTTP(response, request)
270270

271271
_ = json.NewDecoder(response.Body).Decode(&body)
272-
assert.Equal(t, "No Device found with the name UnknownDevice1", body["error"])
272+
assert.Equal(t, "no Device found with the name UnknownDevice1", body["error"])
273273
}
274274

275275
func TestRobotDeviceCommands(t *testing.T) {
@@ -294,7 +294,7 @@ func TestRobotDeviceCommands(t *testing.T) {
294294
)
295295
a.ServeHTTP(response, request)
296296
_ = json.NewDecoder(response.Body).Decode(&body)
297-
assert.Equal(t, "No Device found with the name UnknownDevice1", body["error"])
297+
assert.Equal(t, "no Device found with the name UnknownDevice1", body["error"])
298298
}
299299

300300
func TestExecuteRobotDeviceCommand(t *testing.T) {
@@ -334,7 +334,7 @@ func TestExecuteRobotDeviceCommand(t *testing.T) {
334334
a.ServeHTTP(response, request)
335335

336336
_ = json.NewDecoder(response.Body).Decode(&body)
337-
assert.Equal(t, "No Device found with the name UnknownDevice1", body.(map[string]interface{})["error"])
337+
assert.Equal(t, "no Device found with the name UnknownDevice1", body.(map[string]interface{})["error"])
338338
}
339339

340340
func TestRobotConnections(t *testing.T) {
@@ -379,7 +379,7 @@ func TestRobotConnection(t *testing.T) {
379379
)
380380
a.ServeHTTP(response, request)
381381
_ = json.NewDecoder(response.Body).Decode(&body)
382-
assert.Equal(t, "No Connection found with the name UnknownConnection1", body["error"])
382+
assert.Equal(t, "no Connection found with the name UnknownConnection1", body["error"])
383383
}
384384

385385
func TestRobotDeviceEvent(t *testing.T) {

0 commit comments

Comments
 (0)