Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go1.24 support #5224

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
GO_VERSION: '1.23'
GO_VERSION: '1.24.0-rc.3'
NODE_VERSION: '20.x'
CGO_ENABLED: 0
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
GO_VERSION: "1.23"
GO_VERSION: '1.24.0-rc.3'

jobs:
update-gha-assets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
GO_VERSION: '1.23'
GO_VERSION: '1.24.0-rc.3'
NODE_VERSION: '20.x'
CGO_ENABLED: 0

Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
GO_VERSION: '1.23'
GO_VERSION: '1.24.0-rc.3'

jobs:
# Check if there is any dirty change for go mod tidy
Expand Down Expand Up @@ -40,7 +40,9 @@ jobs:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
go-version: ${{ env.GO_VERSION }}
# TODO(ldez) must be changed after the first release of golangci-lint with go1.24
# go-version: ${{ env.GO_VERSION }}
go-version: '1.23'
- name: lint
uses: golangci/[email protected]
with:
Expand Down Expand Up @@ -76,8 +78,8 @@ jobs:
- ubuntu-latest
- ubuntu-24.04-arm
golang:
- '1.22'
- '1.23'
- '1.24.0-rc.3'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
GO_VERSION: '1.23'
GO_VERSION: '1.24.0-rc.3'
CHOCOLATEY_VERSION: 2.2.0
steps:
# temporary workaround for an error in free disk space action
Expand Down
6 changes: 2 additions & 4 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ linters:
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exhaustruct
- exportloopref
- exptostd
- fatcontext
- forbidigo
Expand Down Expand Up @@ -149,10 +147,8 @@ linters:
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exhaustruct
- exportloopref
- exptostd
- fatcontext
- forbidigo
Expand Down Expand Up @@ -241,7 +237,9 @@ linters:
- wsl
- zerologlint
- deadcode # Deprecated
- execinquery # Deprecated
- exhaustivestruct # Deprecated
- exportloopref # Deprecated
- golint # Deprecated
- gomnd # Deprecated
- ifshort # Deprecated
Expand Down
4 changes: 2 additions & 2 deletions docs/src/docs/welcome/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ docker run -t --rm -v $(pwd):/app -w /app golangci/golangci-lint:{.LatestVersion

### Install from Sources

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

We recommend using binary installation.

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

1. Those installations are compiling golangci-lint locally, the Go version used to build will depend on your local Go version.
2. Some users use `-u` flag for `go get`, which upgrades our dependencies. Resulting binary was not tested and is not guaranteed to work.
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.
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.
4. We've encountered issues with Go modules hashes due to unexpected recreation of dependency tags.
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.
6. It allows installation from main branch which can't be considered stable.
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/golangci/golangci-lint

go 1.22.1
go 1.23.0

require (
4d63.com/gocheckcompilerdirectives v1.2.1
Expand Down Expand Up @@ -63,7 +63,6 @@ require (
github.com/kkHAIKE/contextcheck v1.1.5
github.com/kulti/thelper v0.6.3
github.com/kunwardeep/paralleltest v1.0.10
github.com/kyoh86/exportloopref v0.1.11
github.com/lasiar/canonicalheader v1.1.2
github.com/ldez/exptostd v0.4.0
github.com/ldez/gomoddirectives v0.6.1
Expand Down Expand Up @@ -126,7 +125,6 @@ require (
go-simpler.org/musttag v0.13.0
go-simpler.org/sloglint v0.7.2
go.uber.org/automaxprocs v1.6.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/mod v0.23.0
golang.org/x/sys v0.30.0
golang.org/x/tools v0.29.0
Expand Down Expand Up @@ -196,6 +194,7 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/text v0.21.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"encoding/hex"
"errors"
"fmt"
"maps"
"runtime"
"slices"
"strings"
"sync"

"golang.org/x/exp/maps"
"golang.org/x/tools/go/packages"

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

imps := maps.Values(pkg.Imports)

slices.SortFunc(imps, func(a, b *packages.Package) int {
imps := slices.SortedFunc(maps.Values(pkg.Imports), func(a, b *packages.Package) int {
return strings.Compare(a.PkgPath, b.PkgPath)
})

Expand Down
1 change: 0 additions & 1 deletion jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@
"errorlint",
"exhaustive",
"exhaustruct",
"exportloopref",
"exptostd",
"fatcontext",
"forbidigo",
Expand Down
7 changes: 3 additions & 4 deletions pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"fmt"
"io"
"log"
"maps"
"os"
"path/filepath"
"runtime"
"runtime/pprof"
"runtime/trace"
"sort"
"slices"
"strconv"
"strings"
"time"
Expand All @@ -24,7 +25,6 @@ import (
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/automaxprocs/maxprocs"
"golang.org/x/exp/maps"
"gopkg.in/yaml.v3"

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

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

keys := maps.Keys(stats)
sort.Strings(keys)
keys := slices.Sorted(maps.Keys(stats))

for _, key := range keys {
c.cmd.Printf("* %s: %d\n", key, stats[key])
Expand Down
10 changes: 5 additions & 5 deletions pkg/goanalysis/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"encoding/gob"
"fmt"
"go/token"
"maps"
"runtime"
"sort"
"slices"
"sync"

"golang.org/x/exp/maps"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/packages"

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

paths := maps.Keys(pkg.Imports)
sort.Strings(paths) // for determinism
paths := slices.Sorted(maps.Keys(pkg.Imports)) // for determinism

for _, path := range paths {
dep := r.makeAction(a, pkg.Imports[path], initialPkgs, actions, actAlloc)
act.Deps = append(act.Deps, dep)
Expand Down Expand Up @@ -209,7 +209,7 @@ func (r *runner) prepareAnalysis(pkgs []*packages.Package,
}
}

allActions = maps.Values(actions)
allActions = slices.Collect(maps.Values(actions))

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

Expand Down
19 changes: 0 additions & 19 deletions pkg/golinters/exportloopref/exportloopref.go

This file was deleted.

11 changes: 0 additions & 11 deletions pkg/golinters/exportloopref/exportloopref_integration_test.go

This file was deleted.

46 changes: 0 additions & 46 deletions pkg/golinters/exportloopref/testdata/exportloopref.go

This file was deleted.

Loading
Loading