Skip to content

Commit 474fdaf

Browse files
authored
go1.24 support (#5224)
1 parent e21ee9a commit 474fdaf

File tree

31 files changed

+94
-261
lines changed

31 files changed

+94
-261
lines changed

.github/workflows/documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
# ex:
1717
# - 1.18beta1 -> 1.18.0-beta.1
1818
# - 1.18rc1 -> 1.18.0-rc.1
19-
GO_VERSION: '1.23'
19+
GO_VERSION: '1.24'
2020
NODE_VERSION: '20.x'
2121
CGO_ENABLED: 0
2222
steps:

.github/workflows/post-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
# ex:
1010
# - 1.18beta1 -> 1.18.0-beta.1
1111
# - 1.18rc1 -> 1.18.0-rc.1
12-
GO_VERSION: "1.23"
12+
GO_VERSION: '1.24'
1313

1414
jobs:
1515
update-gha-assets:

.github/workflows/pr-documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
# ex:
1414
# - 1.18beta1 -> 1.18.0-beta.1
1515
# - 1.18rc1 -> 1.18.0-rc.1
16-
GO_VERSION: '1.23'
16+
GO_VERSION: '1.24'
1717
NODE_VERSION: '20.x'
1818
CGO_ENABLED: 0
1919

.github/workflows/pr.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
# ex:
1212
# - 1.18beta1 -> 1.18.0-beta.1
1313
# - 1.18rc1 -> 1.18.0-rc.1
14-
GO_VERSION: '1.23'
14+
GO_VERSION: '1.24'
1515

1616
jobs:
1717
# Check if there is any dirty change for go mod tidy
@@ -40,7 +40,9 @@ jobs:
4040
# ex:
4141
# - 1.18beta1 -> 1.18.0-beta.1
4242
# - 1.18rc1 -> 1.18.0-rc.1
43-
go-version: ${{ env.GO_VERSION }}
43+
# TODO(ldez) must be changed after the first release of golangci-lint with go1.24
44+
# go-version: ${{ env.GO_VERSION }}
45+
go-version: '1.23'
4446
- name: lint
4547
uses: golangci/[email protected]
4648
with:
@@ -76,8 +78,8 @@ jobs:
7678
- ubuntu-latest
7779
- ubuntu-24.04-arm
7880
golang:
79-
- '1.22'
8081
- '1.23'
82+
- '1.24'
8183
runs-on: ${{ matrix.os }}
8284
steps:
8385
- uses: actions/checkout@v4

.github/workflows/tag.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
# ex:
1313
# - 1.18beta1 -> 1.18.0-beta.1
1414
# - 1.18rc1 -> 1.18.0-rc.1
15-
GO_VERSION: '1.23'
15+
GO_VERSION: '1.24'
1616
CHOCOLATEY_VERSION: 2.2.0
1717
steps:
1818
# temporary workaround for an error in free disk space action

.golangci.next.reference.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ linters:
3131
- errchkjson
3232
- errname
3333
- errorlint
34-
- execinquery
3534
- exhaustive
3635
- exhaustruct
37-
- exportloopref
3836
- exptostd
3937
- fatcontext
4038
- forbidigo
@@ -149,10 +147,8 @@ linters:
149147
- errchkjson
150148
- errname
151149
- errorlint
152-
- execinquery
153150
- exhaustive
154151
- exhaustruct
155-
- exportloopref
156152
- exptostd
157153
- fatcontext
158154
- forbidigo
@@ -241,7 +237,9 @@ linters:
241237
- wsl
242238
- zerologlint
243239
- deadcode # Deprecated
240+
- execinquery # Deprecated
244241
- exhaustivestruct # Deprecated
242+
- exportloopref # Deprecated
245243
- golint # Deprecated
246244
- gomnd # Deprecated
247245
- ifshort # Deprecated

docs/src/docs/welcome/install.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ docker run -t --rm -v $(pwd):/app -w /app golangci/golangci-lint:{.LatestVersion
134134

135135
### Install from Sources
136136

137-
Such `go install`/`go get` or "tools pattern" installations aren't guaranteed to work.
137+
Such `go install`/`go get`, "tools pattern", and `tool` command/directives installations aren't guaranteed to work.
138138

139139
We recommend using binary installation.
140140

141141
Those installations aren't recommended because of the following points:
142142

143143
1. Those installations are compiling golangci-lint locally, the Go version used to build will depend on your local Go version.
144144
2. Some users use `-u` flag for `go get`, which upgrades our dependencies. Resulting binary was not tested and is not guaranteed to work.
145-
3. When using "tools pattern", the dependencies of a tool can modify the dependencies of another. Resulting binary was not tested and is not guaranteed to work.
145+
3. When using "tools pattern" or and `tool` command/directives, the dependencies of a tool can modify the dependencies of another or your project. Resulting binary was not tested and is not guaranteed to work.
146146
4. We've encountered issues with Go modules hashes due to unexpected recreation of dependency tags.
147147
5. `go.mod` replacement directives don't apply transitively. It means a user will be using patched version of `golangci-lint` if we use such replacements.
148148
6. It allows installation from main branch which can't be considered stable.

go.mod

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/golangci/golangci-lint
22

3-
go 1.22.1
3+
go 1.23.0
44

55
require (
66
4d63.com/gocheckcompilerdirectives v1.2.1
@@ -63,7 +63,6 @@ require (
6363
github.com/kkHAIKE/contextcheck v1.1.5
6464
github.com/kulti/thelper v0.6.3
6565
github.com/kunwardeep/paralleltest v1.0.10
66-
github.com/kyoh86/exportloopref v0.1.11
6766
github.com/lasiar/canonicalheader v1.1.2
6867
github.com/ldez/exptostd v0.4.1
6968
github.com/ldez/gomoddirectives v0.6.1
@@ -126,7 +125,6 @@ require (
126125
go-simpler.org/musttag v0.13.0
127126
go-simpler.org/sloglint v0.9.0
128127
go.uber.org/automaxprocs v1.6.0
129-
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
130128
golang.org/x/mod v0.23.0
131129
golang.org/x/sys v0.30.0
132130
golang.org/x/tools v0.30.0
@@ -196,6 +194,7 @@ require (
196194
go.uber.org/atomic v1.7.0 // indirect
197195
go.uber.org/multierr v1.6.0 // indirect
198196
go.uber.org/zap v1.24.0 // indirect
197+
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
199198
golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect
200199
golang.org/x/sync v0.11.0 // indirect
201200
golang.org/x/text v0.21.0 // indirect

go.sum

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cache/cache.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"encoding/hex"
77
"errors"
88
"fmt"
9+
"maps"
910
"runtime"
1011
"slices"
1112
"strings"
1213
"sync"
1314

14-
"golang.org/x/exp/maps"
1515
"golang.org/x/tools/go/packages"
1616

1717
"github.com/golangci/golangci-lint/internal/go/cache"
@@ -178,9 +178,7 @@ func (c *Cache) computePkgHash(pkg *packages.Package) (hashResults, error) {
178178
curSum := key.Sum()
179179
hashRes[HashModeNeedOnlySelf] = hex.EncodeToString(curSum[:])
180180

181-
imps := maps.Values(pkg.Imports)
182-
183-
slices.SortFunc(imps, func(a, b *packages.Package) int {
181+
imps := slices.SortedFunc(maps.Values(pkg.Imports), func(a, b *packages.Package) int {
184182
return strings.Compare(a.PkgPath, b.PkgPath)
185183
})
186184

jsonschema/golangci.next.jsonschema.json

-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@
351351
"errorlint",
352352
"exhaustive",
353353
"exhaustruct",
354-
"exportloopref",
355354
"exptostd",
356355
"fatcontext",
357356
"forbidigo",

pkg/commands/run.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import (
88
"fmt"
99
"io"
1010
"log"
11+
"maps"
1112
"os"
1213
"path/filepath"
1314
"runtime"
1415
"runtime/pprof"
1516
"runtime/trace"
16-
"sort"
17+
"slices"
1718
"strconv"
1819
"strings"
1920
"time"
@@ -24,7 +25,6 @@ import (
2425
"github.com/spf13/pflag"
2526
"github.com/spf13/viper"
2627
"go.uber.org/automaxprocs/maxprocs"
27-
"golang.org/x/exp/maps"
2828
"gopkg.in/yaml.v3"
2929

3030
"github.com/golangci/golangci-lint/internal/cache"
@@ -452,8 +452,7 @@ func (c *runCommand) printStats(issues []result.Issue) {
452452

453453
c.cmd.Printf("%d issues:\n", len(issues))
454454

455-
keys := maps.Keys(stats)
456-
sort.Strings(keys)
455+
keys := slices.Sorted(maps.Keys(stats))
457456

458457
for _, key := range keys {
459458
c.cmd.Printf("* %s: %d\n", key, stats[key])

pkg/goanalysis/runner.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"encoding/gob"
99
"fmt"
1010
"go/token"
11+
"maps"
1112
"runtime"
12-
"sort"
13+
"slices"
1314
"sync"
1415

15-
"golang.org/x/exp/maps"
1616
"golang.org/x/tools/go/analysis"
1717
"golang.org/x/tools/go/packages"
1818

@@ -159,8 +159,8 @@ func (r *runner) buildActionFactDeps(act *action, a *analysis.Analyzer, pkg *pac
159159
act.objectFacts = make(map[objectFactKey]analysis.Fact)
160160
act.packageFacts = make(map[packageFactKey]analysis.Fact)
161161

162-
paths := maps.Keys(pkg.Imports)
163-
sort.Strings(paths) // for determinism
162+
paths := slices.Sorted(maps.Keys(pkg.Imports)) // for determinism
163+
164164
for _, path := range paths {
165165
dep := r.makeAction(a, pkg.Imports[path], initialPkgs, actions, actAlloc)
166166
act.Deps = append(act.Deps, dep)
@@ -209,7 +209,7 @@ func (r *runner) prepareAnalysis(pkgs []*packages.Package,
209209
}
210210
}
211211

212-
allActions = maps.Values(actions)
212+
allActions = slices.Collect(maps.Values(actions))
213213

214214
debugf("Built %d actions", len(actions))
215215

pkg/golinters/exportloopref/exportloopref.go

-19
This file was deleted.

pkg/golinters/exportloopref/exportloopref_integration_test.go

-11
This file was deleted.

pkg/golinters/exportloopref/testdata/exportloopref.go

-46
This file was deleted.

0 commit comments

Comments
 (0)