Skip to content

Commit e23677e

Browse files
committed
Merge branch 'main' into gofuncor
2 parents 51efe46 + ec2da93 commit e23677e

20 files changed

+259
-64
lines changed

.golangci.next.reference.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,14 @@ linters:
641641
ignore-calls: false
642642
# Exclude strings matching the given regular expression.
643643
# Default: ""
644-
ignore-strings: 'foo.+'
644+
ignore-string-values:
645+
- 'foo.+'
646+
# Detects constants with identical values.
647+
# Default: false
648+
find-duplicates: true
649+
# Evaluates of constant expressions like Prefix + "suffix".
650+
# Default: false
651+
eval-const-expressions: true
645652

646653
gocritic:
647654
# Disable all checks.
@@ -1590,6 +1597,8 @@ linters:
15901597
- findcall
15911598
# Report assembly that clobbers the frame pointer before saving it.
15921599
- framepointer
1600+
# Report using Go 1.22 enhanced ServeMux patterns in older Go versions.
1601+
- httpmux
15931602
# Check for mistakes using HTTP responses.
15941603
- httpresponse
15951604
# Detect impossible interface-to-interface type assertions.
@@ -1671,6 +1680,7 @@ linters:
16711680
- fieldalignment
16721681
- findcall
16731682
- framepointer
1683+
- httpmux
16741684
- httpresponse
16751685
- ifaceassert
16761686
- loopclosure

.pre-commit-hooks.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@
88
pass_filenames: false
99
- id: golangci-lint-full
1010
name: golangci-lint-full
11-
description: Fast linters runner for Go. Runs on all files in the repo. Use this hook if you use pre-commit in CI.
11+
description: Fast linters runner for Go. Runs on all files in the module. Use this hook if you use pre-commit in CI.
1212
entry: golangci-lint run --fix
1313
types: [go]
1414
language: golang
1515
require_serial: true
1616
pass_filenames: false
17+
- id: golangci-lint-fmt
18+
name: golangci-lint-fmt
19+
description: Fast linters runner for Go. Formats all files in the repo.
20+
entry: golangci-lint fmt
21+
types: [go]
22+
language: golang
23+
require_serial: true
24+
pass_filenames: false
1725
- id: golangci-lint-config-verify
1826
name: golangci-lint-config-verify
1927
description: Verifies the configuration file

docs/src/docs/welcome/integrations.mdx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ Install [plugin](https://plugins.jetbrains.com/plugin/12496-go-linter).
1212

1313
### Visual Studio Code
1414

15-
The integration for golangci-lint v2 is currently in work in progress: [vscode-go#3732](https://github.com/golang/vscode-go/issues/3732).
16-
1715
Install the [extension](https://marketplace.visualstudio.com/items?itemName=golang.Go).
1816

1917
<details>
20-
<summary style={{color: '#737380'}}>Recommended settings</summary>
18+
<summary style={{color: '#737380'}}>Recommended settings for those who installed golangci-lint manually</summary>
2119

2220
```json
2321
"go.lintTool": "golangci-lint",
@@ -35,7 +33,34 @@ Install the [extension](https://marketplace.visualstudio.com/items?itemName=gola
3533
```
3634

3735
Using it in an editor without `--fast-only` can freeze your editor.
38-
Golangci-lint automatically discovers `.golangci.yml` config for edited file: you don't need to configure it in VS Code settings.
36+
Golangci-lint automatically discovers the `.golangci.yml` config for the edited file, so you don't need to configure it in VS Code settings.
37+
38+
</details>
39+
40+
<details>
41+
<summary style={{color: '#737380'}}>Recommended settings for those who installed golangci-lint via extension</summary>
42+
43+
Install `golangci-lint-v2` via the `Go: Install/Update Tools` command after setting these configs.
44+
This will enable golangci-lint v1 to co-exist with v2.
45+
And use the following settings:
46+
47+
```json
48+
"go.lintTool": "golangci-lint-v2",
49+
"go.lintFlags": [
50+
"--fast-only"
51+
],
52+
"go.formatTool": "custom",
53+
"go.alternateTools": {
54+
"customFormatter": "golangci-lint-v2"
55+
},
56+
"go.formatFlags": [
57+
"fmt",
58+
"--stdin"
59+
]
60+
```
61+
62+
Using it in an editor without `--fast-only` can freeze your editor.
63+
Golangci-lint automatically discovers the `.golangci.yml` config for the edited file, so you don't need to configure it in VS Code settings.
3964

4065
</details>
4166

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/bombsimon/wsl/v4 v4.7.0
2929
github.com/breml/bidichk v0.3.3
3030
github.com/breml/errchkjson v0.4.1
31-
github.com/butuzov/ireturn v0.3.1
31+
github.com/butuzov/ireturn v0.4.0
3232
github.com/butuzov/mirror v1.3.0
3333
github.com/catenacyber/perfsprint v0.9.1
3434
github.com/charithe/durationcheck v0.0.10
@@ -52,12 +52,12 @@ require (
5252
github.com/golangci/misspell v0.6.0
5353
github.com/golangci/plugin-module-register v0.1.1
5454
github.com/golangci/revgrep v0.8.0
55-
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed
55+
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e
5656
github.com/gordonklaus/ineffassign v0.1.0
5757
github.com/gostaticanalysis/forcetypeassert v0.2.0
5858
github.com/gostaticanalysis/nilerr v0.1.1
5959
github.com/hashicorp/go-version v1.7.0
60-
github.com/jgautheron/goconst v1.7.1
60+
github.com/jgautheron/goconst v1.8.1
6161
github.com/jingyugao/rowserrcheck v1.1.1
6262
github.com/jjti/go-spancheck v0.6.4
6363
github.com/julz/importas v0.2.0
@@ -86,7 +86,7 @@ require (
8686
github.com/nishanths/exhaustive v0.12.0
8787
github.com/nishanths/predeclared v0.2.2
8888
github.com/nunnatsa/ginkgolinter v0.19.1
89-
github.com/pelletier/go-toml/v2 v2.2.3
89+
github.com/pelletier/go-toml/v2 v2.2.4
9090
github.com/polyfloyd/go-errorlint v1.8.0
9191
github.com/quasilyte/go-ruleguard/dsl v0.3.22
9292
github.com/raeperd/recvcheck v0.2.0
@@ -112,7 +112,7 @@ require (
112112
github.com/tdakkota/asciicheck v0.4.1
113113
github.com/tetafro/godot v1.5.0
114114
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67
115-
github.com/timonwong/loggercheck v0.10.1
115+
github.com/timonwong/loggercheck v0.11.0
116116
github.com/tomarrell/wrapcheck/v2 v2.11.0
117117
github.com/tommy-muehle/go-mnd/v2 v2.5.1
118118
github.com/ultraware/funlen v0.2.0
@@ -130,7 +130,7 @@ require (
130130
go.uber.org/automaxprocs v1.6.0
131131
golang.org/x/mod v0.24.0
132132
golang.org/x/sys v0.32.0
133-
golang.org/x/tools v0.31.0
133+
golang.org/x/tools v0.32.0
134134
gopkg.in/yaml.v3 v3.0.1
135135
honnef.co/go/tools v0.6.1
136136
mvdan.cc/gofumpt v0.7.0
@@ -209,7 +209,7 @@ require (
209209
go.uber.org/zap v1.24.0 // indirect
210210
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
211211
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
212-
golang.org/x/sync v0.12.0 // indirect
212+
golang.org/x/sync v0.13.0 // indirect
213213
golang.org/x/text v0.23.0 // indirect
214214
google.golang.org/protobuf v1.36.6 // indirect
215215
gopkg.in/ini.v1 v1.67.0 // indirect

go.sum

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@
539539
"fieldalignment",
540540
"findcall",
541541
"framepointer",
542+
"httpmux",
542543
"httpresponse",
543544
"ifaceassert",
544545
"loopclosure",
@@ -1487,9 +1488,12 @@
14871488
"type": "boolean",
14881489
"default": true
14891490
},
1490-
"ignore-strings": {
1491+
"ignore-string-values": {
14911492
"description": "Exclude strings matching the given regular expression",
1492-
"type": "string"
1493+
"type": "array",
1494+
"items": {
1495+
"type": "string"
1496+
}
14931497
},
14941498
"numbers": {
14951499
"description": "Search also for duplicated numbers.",
@@ -1505,6 +1509,16 @@
15051509
"description": "Maximum value, only works with `numbers`",
15061510
"type": "integer",
15071511
"default": 3
1512+
},
1513+
"find-duplicates": {
1514+
"description": "Detects constants with identical values",
1515+
"type": "boolean",
1516+
"default": false
1517+
},
1518+
"eval-const-expressions": {
1519+
"description": "Evaluates of constant expressions like Prefix + \"suffix\"",
1520+
"type": "boolean",
1521+
"default": false
15081522
}
15091523
}
15101524
},

pkg/config/linters_settings.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,19 @@ type GocognitSettings struct {
457457
}
458458

459459
type GoConstSettings struct {
460-
IgnoreStrings string `mapstructure:"ignore-strings"`
461-
MatchWithConstants bool `mapstructure:"match-constant"`
462-
MinStringLen int `mapstructure:"min-len"`
463-
MinOccurrencesCount int `mapstructure:"min-occurrences"`
464-
ParseNumbers bool `mapstructure:"numbers"`
465-
NumberMin int `mapstructure:"min"`
466-
NumberMax int `mapstructure:"max"`
467-
IgnoreCalls bool `mapstructure:"ignore-calls"`
460+
IgnoreStringValues []string `mapstructure:"ignore-string-values"`
461+
MatchWithConstants bool `mapstructure:"match-constant"`
462+
MinStringLen int `mapstructure:"min-len"`
463+
MinOccurrencesCount int `mapstructure:"min-occurrences"`
464+
ParseNumbers bool `mapstructure:"numbers"`
465+
NumberMin int `mapstructure:"min"`
466+
NumberMax int `mapstructure:"max"`
467+
IgnoreCalls bool `mapstructure:"ignore-calls"`
468+
FindDuplicates bool `mapstructure:"find-duplicates"`
469+
EvalConstExpressions bool `mapstructure:"eval-const-expressions"`
470+
471+
// Deprecated: use IgnoreStringValues instead.
472+
IgnoreStrings string `mapstructure:"ignore-strings"`
468473
}
469474

470475
type GoCriticSettings struct {

pkg/config/loader.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,15 @@ func (l *Loader) handleDeprecation() error {
190190
return nil
191191
}
192192

193-
func (*Loader) handleLinterOptionDeprecations() {
194-
// The function is empty but deprecations will happen in the future.
193+
func (l *Loader) handleLinterOptionDeprecations() {
194+
// Deprecated since v2.1.0.
195+
if l.cfg.Linters.Settings.Goconst.IgnoreStrings != "" {
196+
l.log.Warnf("The configuration option `linters.settings.goconst.ignore-strings` is deprecated, " +
197+
"please use `linters.settings.goconst.ignore-string-values`.")
198+
199+
l.cfg.Linters.Settings.Goconst.IgnoreStringValues = append(l.cfg.Linters.Settings.Goconst.IgnoreStringValues,
200+
l.cfg.Linters.Settings.Goconst.IgnoreStrings)
201+
}
195202
}
196203

197204
func (l *Loader) handleEnableOnlyOption() error {

0 commit comments

Comments
 (0)