diff --git a/.github/workflows/deploy-documentation.yml b/.github/workflows/deploy-documentation.yml index da7a8e7d7983..e8ee4965d3ad 100644 --- a/.github/workflows/deploy-documentation.yml +++ b/.github/workflows/deploy-documentation.yml @@ -15,7 +15,7 @@ jobs: # ex: # - 1.18beta1 -> 1.18.0-beta.1 # - 1.18rc1 -> 1.18.0-rc.1 - GO_VERSION: '1.24' + GO_VERSION: '1.25.0-rc.1' NODE_VERSION: '20.x' CGO_ENABLED: 0 steps: diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index d618b4c58c11..79b7cca202ec 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -9,7 +9,7 @@ env: # ex: # - 1.18beta1 -> 1.18.0-beta.1 # - 1.18rc1 -> 1.18.0-rc.1 - GO_VERSION: '1.24' + GO_VERSION: '1.25.0-rc.1' jobs: update-gha-assets: diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index f5c69841abef..7319524ad944 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -10,7 +10,7 @@ env: # ex: # - 1.18beta1 -> 1.18.0-beta.1 # - 1.18rc1 -> 1.18.0-rc.1 - GO_VERSION: '1.24' + GO_VERSION: '1.25.0-rc.1' jobs: # Check if there is any dirty change for go mod tidy diff --git a/.github/workflows/pr-documentation.yml b/.github/workflows/pr-documentation.yml index bdd9043cb6b2..31a212472f78 100644 --- a/.github/workflows/pr-documentation.yml +++ b/.github/workflows/pr-documentation.yml @@ -13,7 +13,7 @@ jobs: # ex: # - 1.18beta1 -> 1.18.0-beta.1 # - 1.18rc1 -> 1.18.0-rc.1 - GO_VERSION: '1.24' + GO_VERSION: '1.25.0-rc.1' NODE_VERSION: '20.x' CGO_ENABLED: 0 diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index 5f5606e97835..112bb1920b96 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -10,7 +10,7 @@ env: # ex: # - 1.18beta1 -> 1.18.0-beta.1 # - 1.18rc1 -> 1.18.0-rc.1 - GO_VERSION: '1.24' + GO_VERSION: '1.25.0-rc.1' jobs: # Check if there is any dirty change for go mod tidy @@ -39,7 +39,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.24' - name: lint uses: golangci/golangci-lint-action@v8.0.0 with: @@ -75,8 +77,8 @@ jobs: - ubuntu-latest - ubuntu-24.04-arm golang: - - '1.23' - '1.24' + - '1.25.0-rc.1' runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a75cb50cfe3..57a4e31b1fa7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: # ex: # - 1.18beta1 -> 1.18.0-beta.1 # - 1.18rc1 -> 1.18.0-rc.1 - GO_VERSION: '1.24' + GO_VERSION: '1.25.0-rc.1' CHOCOLATEY_VERSION: 2.2.0 steps: # temporary workaround for an error in free disk space action diff --git a/build/buildx-alpine.Dockerfile b/build/buildx-alpine.Dockerfile index 72b7ad0797b6..c9a3615d67b0 100644 --- a/build/buildx-alpine.Dockerfile +++ b/build/buildx-alpine.Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.4 -FROM golang:1.24-alpine +FROM golang:1.25-alpine # related to https://github.com/golangci/golangci-lint/issues/3107 ENV GOROOT /usr/local/go diff --git a/build/buildx.Dockerfile b/build/buildx.Dockerfile index 3b7c277f823a..bcebe98bbe08 100644 --- a/build/buildx.Dockerfile +++ b/build/buildx.Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.4 -FROM golang:1.24 +FROM golang:1.25 # related to https://github.com/golangci/golangci-lint/issues/3107 ENV GOROOT /usr/local/go diff --git a/go.mod b/go.mod index a4d2c42154cd..7e960b07b203 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/golangci/golangci-lint/v2 -go 1.23.0 +go 1.24.0 require ( 4d63.com/gocheckcompilerdirectives v1.3.0 diff --git a/pkg/commands/internal/migrate/versionone/output.go b/pkg/commands/internal/migrate/versionone/output.go index 408a07ab6577..a3d86fc1d233 100644 --- a/pkg/commands/internal/migrate/versionone/output.go +++ b/pkg/commands/internal/migrate/versionone/output.go @@ -24,9 +24,7 @@ type OutputFormat struct { type OutputFormats []OutputFormat func (p *OutputFormats) UnmarshalText(text []byte) error { - formats := strings.Split(string(text), ",") - - for _, item := range formats { + for item := range strings.SplitSeq(string(text), ",") { format, path, _ := strings.Cut(item, ":") *p = append(*p, OutputFormat{ diff --git a/pkg/goformatters/gci/internal/section/standard_list.go b/pkg/goformatters/gci/internal/section/standard_list.go index 2fddded70cc0..34cf38cec56e 100644 --- a/pkg/goformatters/gci/internal/section/standard_list.go +++ b/pkg/goformatters/gci/internal/section/standard_list.go @@ -1,182 +1,185 @@ package section -// Code generated based on go1.24.0 X:boringcrypto,arenas,synctest. DO NOT EDIT. +// Code generated based on go1.25rc1 X:boringcrypto,arenas,synctest,jsonv2. DO NOT EDIT. var standardPackages = map[string]struct{}{ - "archive/tar": {}, - "archive/zip": {}, - "arena": {}, - "bufio": {}, - "bytes": {}, - "cmp": {}, - "compress/bzip2": {}, - "compress/flate": {}, - "compress/gzip": {}, - "compress/lzw": {}, - "compress/zlib": {}, - "container/heap": {}, - "container/list": {}, - "container/ring": {}, - "context": {}, - "crypto": {}, - "crypto/aes": {}, - "crypto/boring": {}, - "crypto/cipher": {}, - "crypto/des": {}, - "crypto/dsa": {}, - "crypto/ecdh": {}, - "crypto/ecdsa": {}, - "crypto/ed25519": {}, - "crypto/elliptic": {}, - "crypto/fips140": {}, - "crypto/hkdf": {}, - "crypto/hmac": {}, - "crypto/md5": {}, - "crypto/mlkem": {}, - "crypto/pbkdf2": {}, - "crypto/rand": {}, - "crypto/rc4": {}, - "crypto/rsa": {}, - "crypto/sha1": {}, - "crypto/sha256": {}, - "crypto/sha3": {}, - "crypto/sha512": {}, - "crypto/subtle": {}, - "crypto/tls": {}, - "crypto/tls/fipsonly": {}, - "crypto/x509": {}, - "crypto/x509/pkix": {}, - "database/sql": {}, - "database/sql/driver": {}, - "debug/buildinfo": {}, - "debug/dwarf": {}, - "debug/elf": {}, - "debug/gosym": {}, - "debug/macho": {}, - "debug/pe": {}, - "debug/plan9obj": {}, - "embed": {}, - "encoding": {}, - "encoding/ascii85": {}, - "encoding/asn1": {}, - "encoding/base32": {}, - "encoding/base64": {}, - "encoding/binary": {}, - "encoding/csv": {}, - "encoding/gob": {}, - "encoding/hex": {}, - "encoding/json": {}, - "encoding/pem": {}, - "encoding/xml": {}, - "errors": {}, - "expvar": {}, - "flag": {}, - "fmt": {}, - "go/ast": {}, - "go/build": {}, - "go/build/constraint": {}, - "go/constant": {}, - "go/doc": {}, - "go/doc/comment": {}, - "go/format": {}, - "go/importer": {}, - "go/parser": {}, - "go/printer": {}, - "go/scanner": {}, - "go/token": {}, - "go/types": {}, - "go/version": {}, - "hash": {}, - "hash/adler32": {}, - "hash/crc32": {}, - "hash/crc64": {}, - "hash/fnv": {}, - "hash/maphash": {}, - "html": {}, - "html/template": {}, - "image": {}, - "image/color": {}, - "image/color/palette": {}, - "image/draw": {}, - "image/gif": {}, - "image/jpeg": {}, - "image/png": {}, - "index/suffixarray": {}, - "io": {}, - "io/fs": {}, - "io/ioutil": {}, - "iter": {}, - "log": {}, - "log/slog": {}, - "log/syslog": {}, - "maps": {}, - "math": {}, - "math/big": {}, - "math/bits": {}, - "math/cmplx": {}, - "math/rand": {}, - "math/rand/v2": {}, - "mime": {}, - "mime/multipart": {}, - "mime/quotedprintable": {}, - "net": {}, - "net/http": {}, - "net/http/cgi": {}, - "net/http/cookiejar": {}, - "net/http/fcgi": {}, - "net/http/httptest": {}, - "net/http/httptrace": {}, - "net/http/httputil": {}, - "net/http/pprof": {}, - "net/mail": {}, - "net/netip": {}, - "net/rpc": {}, - "net/rpc/jsonrpc": {}, - "net/smtp": {}, - "net/textproto": {}, - "net/url": {}, - "os": {}, - "os/exec": {}, - "os/signal": {}, - "os/user": {}, - "path": {}, - "path/filepath": {}, - "plugin": {}, - "reflect": {}, - "regexp": {}, - "regexp/syntax": {}, - "runtime": {}, - "runtime/cgo": {}, - "runtime/coverage": {}, - "runtime/debug": {}, - "runtime/metrics": {}, - "runtime/pprof": {}, - "runtime/race": {}, - "runtime/trace": {}, - "slices": {}, - "sort": {}, - "strconv": {}, - "strings": {}, - "structs": {}, - "sync": {}, - "sync/atomic": {}, - "syscall": {}, - "testing": {}, - "testing/fstest": {}, - "testing/iotest": {}, - "testing/quick": {}, - "testing/slogtest": {}, - "testing/synctest": {}, - "text/scanner": {}, - "text/tabwriter": {}, - "text/template": {}, - "text/template/parse": {}, - "time": {}, - "time/tzdata": {}, - "unicode": {}, - "unicode/utf16": {}, - "unicode/utf8": {}, - "unique": {}, - "unsafe": {}, - "weak": {}, + "archive/tar": {}, + "archive/zip": {}, + "arena": {}, + "bufio": {}, + "bytes": {}, + "cmp": {}, + "compress/bzip2": {}, + "compress/flate": {}, + "compress/gzip": {}, + "compress/lzw": {}, + "compress/zlib": {}, + "container/heap": {}, + "container/list": {}, + "container/ring": {}, + "context": {}, + "crypto": {}, + "crypto/aes": {}, + "crypto/boring": {}, + "crypto/cipher": {}, + "crypto/des": {}, + "crypto/dsa": {}, + "crypto/ecdh": {}, + "crypto/ecdsa": {}, + "crypto/ed25519": {}, + "crypto/elliptic": {}, + "crypto/fips140": {}, + "crypto/hkdf": {}, + "crypto/hmac": {}, + "crypto/md5": {}, + "crypto/mlkem": {}, + "crypto/pbkdf2": {}, + "crypto/rand": {}, + "crypto/rc4": {}, + "crypto/rsa": {}, + "crypto/sha1": {}, + "crypto/sha256": {}, + "crypto/sha3": {}, + "crypto/sha512": {}, + "crypto/subtle": {}, + "crypto/tls": {}, + "crypto/tls/fipsonly": {}, + "crypto/x509": {}, + "crypto/x509/pkix": {}, + "database/sql": {}, + "database/sql/driver": {}, + "debug/buildinfo": {}, + "debug/dwarf": {}, + "debug/elf": {}, + "debug/gosym": {}, + "debug/macho": {}, + "debug/pe": {}, + "debug/plan9obj": {}, + "embed": {}, + "encoding": {}, + "encoding/ascii85": {}, + "encoding/asn1": {}, + "encoding/base32": {}, + "encoding/base64": {}, + "encoding/binary": {}, + "encoding/csv": {}, + "encoding/gob": {}, + "encoding/hex": {}, + "encoding/json": {}, + "encoding/json/jsontext": {}, + "encoding/json/v2": {}, + "encoding/pem": {}, + "encoding/xml": {}, + "errors": {}, + "expvar": {}, + "flag": {}, + "fmt": {}, + "go/ast": {}, + "go/build": {}, + "go/build/constraint": {}, + "go/constant": {}, + "go/doc": {}, + "go/doc/comment": {}, + "go/format": {}, + "go/importer": {}, + "go/parser": {}, + "go/printer": {}, + "go/scanner": {}, + "go/token": {}, + "go/types": {}, + "go/version": {}, + "hash": {}, + "hash/adler32": {}, + "hash/crc32": {}, + "hash/crc64": {}, + "hash/fnv": {}, + "hash/maphash": {}, + "html": {}, + "html/template": {}, + "image": {}, + "image/color": {}, + "image/color/palette": {}, + "image/draw": {}, + "image/gif": {}, + "image/jpeg": {}, + "image/png": {}, + "index/suffixarray": {}, + "io": {}, + "io/fs": {}, + "io/ioutil": {}, + "iter": {}, + "log": {}, + "log/slog": {}, + "log/syslog": {}, + "maps": {}, + "math": {}, + "math/big": {}, + "math/bits": {}, + "math/cmplx": {}, + "math/rand": {}, + "math/rand/v2": {}, + "mime": {}, + "mime/multipart": {}, + "mime/quotedprintable": {}, + "net": {}, + "net/http": {}, + "net/http/cgi": {}, + "net/http/cookiejar": {}, + "net/http/fcgi": {}, + "net/http/httptest": {}, + "net/http/httptrace": {}, + "net/http/httputil": {}, + "net/http/pprof": {}, + "net/mail": {}, + "net/netip": {}, + "net/rpc": {}, + "net/rpc/jsonrpc": {}, + "net/smtp": {}, + "net/textproto": {}, + "net/url": {}, + "os": {}, + "os/exec": {}, + "os/signal": {}, + "os/user": {}, + "path": {}, + "path/filepath": {}, + "plugin": {}, + "reflect": {}, + "regexp": {}, + "regexp/syntax": {}, + "runtime": {}, + "runtime/cgo": {}, + "runtime/coverage": {}, + "runtime/debug": {}, + "runtime/metrics": {}, + "runtime/pprof": {}, + "runtime/race": {}, + "runtime/trace": {}, + "slices": {}, + "sort": {}, + "strconv": {}, + "strings": {}, + "structs": {}, + "sync": {}, + "sync/atomic": {}, + "syscall": {}, + "syscall/js": {}, + "testing": {}, + "testing/fstest": {}, + "testing/iotest": {}, + "testing/quick": {}, + "testing/slogtest": {}, + "testing/synctest": {}, + "text/scanner": {}, + "text/tabwriter": {}, + "text/template": {}, + "text/template/parse": {}, + "time": {}, + "time/tzdata": {}, + "unicode": {}, + "unicode/utf16": {}, + "unicode/utf8": {}, + "unique": {}, + "unsafe": {}, + "weak": {}, } diff --git a/pkg/golinters/arangolint/testdata/go.mod b/pkg/golinters/arangolint/testdata/go.mod index 0fb1fc8b4a4e..a64eb753353b 100644 --- a/pkg/golinters/arangolint/testdata/go.mod +++ b/pkg/golinters/arangolint/testdata/go.mod @@ -1,6 +1,6 @@ module arangolint -go 1.23.0 +go 1.24.0 require github.com/arangodb/go-driver/v2 v2.1.3 diff --git a/pkg/golinters/exptostd/testdata/go.mod b/pkg/golinters/exptostd/testdata/go.mod index 3bd4f2c04ce5..6553e085f3ba 100644 --- a/pkg/golinters/exptostd/testdata/go.mod +++ b/pkg/golinters/exptostd/testdata/go.mod @@ -1,5 +1,5 @@ module exptostd -go 1.23.0 +go 1.24.0 require golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 diff --git a/pkg/golinters/ginkgolinter/testdata/go.mod b/pkg/golinters/ginkgolinter/testdata/go.mod index 078968acadbb..55b035b23aac 100644 --- a/pkg/golinters/ginkgolinter/testdata/go.mod +++ b/pkg/golinters/ginkgolinter/testdata/go.mod @@ -1,6 +1,6 @@ module ginkgolinter -go 1.23.0 +go 1.24.0 require ( github.com/onsi/ginkgo/v2 v2.23.4 diff --git a/pkg/golinters/gomodguard/testdata/go.mod b/pkg/golinters/gomodguard/testdata/go.mod index c5512cba7f95..5ab7ab11f1eb 100644 --- a/pkg/golinters/gomodguard/testdata/go.mod +++ b/pkg/golinters/gomodguard/testdata/go.mod @@ -1,6 +1,6 @@ module gomodguard -go 1.23.0 +go 1.24.0 require ( golang.org/x/mod v0.24.0 diff --git a/pkg/golinters/loggercheck/testdata/go.mod b/pkg/golinters/loggercheck/testdata/go.mod index 0df788c08b62..19b941401978 100644 --- a/pkg/golinters/loggercheck/testdata/go.mod +++ b/pkg/golinters/loggercheck/testdata/go.mod @@ -1,6 +1,6 @@ module loggercheck -go 1.21.0 +go 1.24.0 require ( github.com/go-kit/log v0.2.1 diff --git a/pkg/golinters/protogetter/testdata/go.mod b/pkg/golinters/protogetter/testdata/go.mod index ac7bf891a2f6..612436d76226 100644 --- a/pkg/golinters/protogetter/testdata/go.mod +++ b/pkg/golinters/protogetter/testdata/go.mod @@ -1,6 +1,6 @@ module protogetter -go 1.23.0 +go 1.24.0 require ( google.golang.org/grpc v1.72.2 diff --git a/pkg/golinters/spancheck/testdata/go.mod b/pkg/golinters/spancheck/testdata/go.mod index 256ae9e1b2a9..77ccc1da909a 100644 --- a/pkg/golinters/spancheck/testdata/go.mod +++ b/pkg/golinters/spancheck/testdata/go.mod @@ -1,6 +1,6 @@ module spancheck -go 1.23.0 +go 1.24.0 require ( go.opentelemetry.io/otel v1.36.0 diff --git a/pkg/golinters/usetesting/testdata/usetesting.go b/pkg/golinters/usetesting/testdata/usetesting.go index 2d724e11da6b..b3e3424301ae 100644 --- a/pkg/golinters/usetesting/testdata/usetesting.go +++ b/pkg/golinters/usetesting/testdata/usetesting.go @@ -2,10 +2,23 @@ package testdata import ( + "context" "os" "testing" ) +func Test_contextBackground(t *testing.T) { + context.Background() +} + +func Test_contextTODO(t *testing.T) { + context.TODO() +} + +func Test_osChdir(t *testing.T) { + os.Chdir("") // want `os\.Chdir\(\) could be replaced by t\.Chdir\(\) in .+` +} + func Test_osMkdirTemp(t *testing.T) { os.MkdirTemp("", "") // want `os\.MkdirTemp\(\) could be replaced by t\.TempDir\(\) in .+` } diff --git a/pkg/golinters/usetesting/testdata/usetesting_configuration.go b/pkg/golinters/usetesting/testdata/usetesting_configuration.go index 332e4ea9b12c..9eaf97c49a38 100644 --- a/pkg/golinters/usetesting/testdata/usetesting_configuration.go +++ b/pkg/golinters/usetesting/testdata/usetesting_configuration.go @@ -3,10 +3,23 @@ package testdata import ( + "context" "os" "testing" ) +func Test_contextBackground(t *testing.T) { + context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+` +} + +func Test_contextTODO(t *testing.T) { + context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+` +} + +func Test_osChdir(t *testing.T) { + os.Chdir("") +} + func Test_osMkdirTemp(t *testing.T) { os.MkdirTemp("", "") } diff --git a/pkg/golinters/usetesting/testdata/usetesting_configuration.yml b/pkg/golinters/usetesting/testdata/usetesting_configuration.yml index e848078d1097..b62936018fc5 100644 --- a/pkg/golinters/usetesting/testdata/usetesting_configuration.yml +++ b/pkg/golinters/usetesting/testdata/usetesting_configuration.yml @@ -8,5 +8,5 @@ linters: os-setenv: true os-temp-dir: true os-chdir: false - context-background: false - context-todo: false + context-background: true + context-todo: true diff --git a/pkg/golinters/usetesting/testdata/usetesting_go124.go b/pkg/golinters/usetesting/testdata/usetesting_go124.go deleted file mode 100644 index 614c87daaf00..000000000000 --- a/pkg/golinters/usetesting/testdata/usetesting_go124.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.24 - -//golangcitest:args -Eusetesting -package testdata - -import ( - "context" - "os" - "testing" -) - -func Test_contextBackground(t *testing.T) { - context.Background() -} - -func Test_contextTODO(t *testing.T) { - context.TODO() -} - -func Test_osChdir(t *testing.T) { - os.Chdir("") // want `os\.Chdir\(\) could be replaced by t\.Chdir\(\) in .+` -} - -func Test_osMkdirTemp(t *testing.T) { - os.MkdirTemp("", "") // want `os\.MkdirTemp\(\) could be replaced by t\.TempDir\(\) in .+` -} - -func Test_osSetenv(t *testing.T) { - os.Setenv("", "") // want `os\.Setenv\(\) could be replaced by t\.Setenv\(\) in .+` -} - -func Test_osTempDir(t *testing.T) { - os.TempDir() -} - -func Test_osCreateTemp(t *testing.T) { - os.CreateTemp("", "") // want `os\.CreateTemp\("", \.\.\.\) could be replaced by os\.CreateTemp\(t\.TempDir\(\), \.\.\.\) in .+` - os.CreateTemp("", "xx") // want `os\.CreateTemp\("", \.\.\.\) could be replaced by os\.CreateTemp\(t\.TempDir\(\), \.\.\.\) in .+` - os.CreateTemp(os.TempDir(), "xx") - os.CreateTemp(t.TempDir(), "xx") -} diff --git a/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.go b/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.go deleted file mode 100644 index 2a1159538dc4..000000000000 --- a/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.go +++ /dev/null @@ -1,42 +0,0 @@ -//go:build go1.24 - -//golangcitest:args -Eusetesting -//golangcitest:config_path testdata/usetesting_go124_configuration.yml -package testdata - -import ( - "context" - "os" - "testing" -) - -func Test_contextBackground(t *testing.T) { - context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+` -} - -func Test_contextTODO(t *testing.T) { - context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+` -} - -func Test_osChdir(t *testing.T) { - os.Chdir("") -} - -func Test_osMkdirTemp(t *testing.T) { - os.MkdirTemp("", "") -} - -func Test_osSetenv(t *testing.T) { - os.Setenv("", "") // want `os\.Setenv\(\) could be replaced by t\.Setenv\(\) in .+` -} - -func Test_osTempDir(t *testing.T) { - os.TempDir() // want `os\.TempDir\(\) could be replaced by t\.TempDir\(\) in .+` -} - -func Test_osCreateTemp(t *testing.T) { - os.CreateTemp("", "") - os.CreateTemp("", "xx") - os.CreateTemp(os.TempDir(), "xx") // want `os\.TempDir\(\) could be replaced by t\.TempDir\(\) in .+` - os.CreateTemp(t.TempDir(), "xx") -} diff --git a/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml b/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml deleted file mode 100644 index b62936018fc5..000000000000 --- a/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: "2" - -linters: - settings: - usetesting: - os-create-temp: false - os-mkdir-temp: false - os-setenv: true - os-temp-dir: true - os-chdir: false - context-background: true - context-todo: true diff --git a/pkg/golinters/zerologlint/testdata/go.mod b/pkg/golinters/zerologlint/testdata/go.mod index 6e255ef19b13..59b4c0379194 100644 --- a/pkg/golinters/zerologlint/testdata/go.mod +++ b/pkg/golinters/zerologlint/testdata/go.mod @@ -1,6 +1,6 @@ module zerologlint -go 1.23.0 +go 1.24.0 require github.com/rs/zerolog v1.34.0 diff --git a/pkg/goutil/version.go b/pkg/goutil/version.go index 4f42ebd1bf6a..77e5b0f351be 100644 --- a/pkg/goutil/version.go +++ b/pkg/goutil/version.go @@ -60,9 +60,7 @@ func CleanRuntimeVersion() (string, error) { } func cleanRuntimeVersion(rv string) (string, error) { - parts := strings.Fields(rv) - - for _, part := range parts { + for part := range strings.FieldsSeq(rv) { // Allow to handle: // - GOEXPERIMENT -> "go1.23.0 X:boringcrypto" // - devel -> "devel go1.24-e705a2d Wed Aug 7 01:16:42 2024 +0000 linux/amd64" diff --git a/pkg/logutils/logutils.go b/pkg/logutils/logutils.go index e417ac4b738d..c48279c6c24b 100644 --- a/pkg/logutils/logutils.go +++ b/pkg/logutils/logutils.go @@ -94,7 +94,7 @@ func getEnabledDebugs() map[string]bool { return ret } - for _, tag := range strings.Split(debugVar, ",") { + for tag := range strings.SplitSeq(debugVar, ",") { ret[tag] = true } diff --git a/pkg/result/processors/nolint_filter.go b/pkg/result/processors/nolint_filter.go index bd2a09abea43..3d92c1b40f6f 100644 --- a/pkg/result/processors/nolint_filter.go +++ b/pkg/result/processors/nolint_filter.go @@ -227,11 +227,12 @@ func (p *NolintFilter) extractInlineRangeFromComment(text string, g ast.Node, fs return buildRange(nil) // ignore all linters } + text = strings.Split(text, "//")[0] // allow another comment after this comment + // ignore specific linters var linters []string - text = strings.Split(text, "//")[0] // allow another comment after this comment - linterItems := strings.Split(strings.TrimPrefix(text, "nolint:"), ",") - for _, item := range linterItems { + + for item := range strings.SplitSeq(strings.TrimPrefix(text, "nolint:"), ",") { linterName := strings.ToLower(strings.TrimSpace(item)) if linterName == "all" { p.unknownLintersSet = map[string]bool{} diff --git a/scripts/gen_github_action_config/go.mod b/scripts/gen_github_action_config/go.mod index 32b5cca642a1..3128ad3256a6 100644 --- a/scripts/gen_github_action_config/go.mod +++ b/scripts/gen_github_action_config/go.mod @@ -1,9 +1,9 @@ module github.com/golangci/golangci-lint/v2/scripts/gen_github_action_config -go 1.23.0 +go 1.24.0 require ( - github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064 + github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7 github.com/stretchr/testify v1.10.0 golang.org/x/oauth2 v0.30.0 ) diff --git a/scripts/gen_github_action_config/go.sum b/scripts/gen_github_action_config/go.sum index 16f1f14cd28c..1f33a087ac60 100644 --- a/scripts/gen_github_action_config/go.sum +++ b/scripts/gen_github_action_config/go.sum @@ -2,8 +2,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064 h1:RCQBSFx5JrsbHltqTtJ+kN3U0Y3a/N/GlVdmRSoxzyE= -github.com/shurcooL/githubv4 v0.0.0-20240429030203-be2daab69064/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8= +github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7 h1:cYCy18SHPKRkvclm+pWm1Lk4YrREb4IOIb/YdFO0p2M= +github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8= github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 h1:17JxqqJY66GmZVHkmAsGEkcIu0oCe3AM420QDgGwZx0= github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466/go.mod h1:9dIRpgIY7hVhoqfe0/FcYp0bpInZaT7dc3BYOprrIUE= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= diff --git a/scripts/gen_github_action_config/main.go b/scripts/gen_github_action_config/main.go index 2324b7de7505..c5600fcbc26e 100644 --- a/scripts/gen_github_action_config/main.go +++ b/scripts/gen_github_action_config/main.go @@ -219,10 +219,9 @@ func parseVersion(s string) (*version, error) { return nil, fmt.Errorf("version %q should start with %q", s, vPrefix) } - parts := strings.Split(strings.TrimPrefix(s, vPrefix), ".") - var nums []int - for _, part := range parts { + + for part := range strings.SplitSeq(strings.TrimPrefix(s, vPrefix), ".") { num, err := strconv.Atoi(part) if err != nil { return nil, fmt.Errorf("failed to parse version %q: %w", s, err) diff --git a/test/bench/bench_test.go b/test/bench/bench_test.go index 18b13039a7a9..12bf005b83b7 100644 --- a/test/bench/bench_test.go +++ b/test/bench/bench_test.go @@ -35,15 +35,6 @@ type metrics struct { } func Benchmark_linters(b *testing.B) { - savedWD, err := os.Getwd() - require.NoError(b, err) - - b.Cleanup(func() { - // Restore WD to avoid side effects when during all the benchmarks. - err = os.Chdir(savedWD) - require.NoError(b, err) - }) - installGolangCILint(b) repos := getAllRepositories(b) @@ -65,8 +56,7 @@ func Benchmark_linters(b *testing.B) { b.Run(repo.name, func(b *testing.B) { _ = exec.Command(binName, "cache", "clean").Run() - err = os.Chdir(repo.dir) - require.NoErrorf(b, err, "can't chdir to %s", repo.dir) + b.Chdir(repo.dir) lc := countGoLines(b) @@ -83,15 +73,6 @@ func Benchmark_linters(b *testing.B) { } func Benchmark_golangciLint(b *testing.B) { - savedWD, err := os.Getwd() - require.NoError(b, err) - - b.Cleanup(func() { - // Restore WD to avoid side effects when during all the benchmarks. - err = os.Chdir(savedWD) - require.NoError(b, err) - }) - installGolangCILint(b) _ = exec.Command(binName, "cache", "clean").Run() @@ -114,8 +95,7 @@ func Benchmark_golangciLint(b *testing.B) { for _, c := range cases { b.Run(c.name, func(b *testing.B) { - err = os.Chdir(c.dir) - require.NoErrorf(b, err, "can't chdir to %s", c.dir) + b.Chdir(c.dir) lc := countGoLines(b) @@ -142,26 +122,26 @@ func getAllRepositories(tb testing.TB) []repo { name: "golangci/golangci-lint", dir: cloneGithubProject(tb, benchRoot, "golangci", "golangci-lint"), }, - { - name: "goreleaser/goreleaser", - dir: cloneGithubProject(tb, benchRoot, "goreleaser", "goreleaser"), - }, - { - name: "gohugoio/hugo", - dir: cloneGithubProject(tb, benchRoot, "gohugoio", "hugo"), - }, - { - name: "pact-foundation/pact-go", // CGO inside - dir: cloneGithubProject(tb, benchRoot, "pact-foundation", "pact-go"), - }, - { - name: "kubernetes/kubernetes", - dir: cloneGithubProject(tb, benchRoot, "kubernetes", "kubernetes"), - }, - { - name: "moby/buildkit", - dir: cloneGithubProject(tb, benchRoot, "moby", "buildkit"), - }, + // { + // name: "goreleaser/goreleaser", + // dir: cloneGithubProject(tb, benchRoot, "goreleaser", "goreleaser"), + // }, + // { + // name: "gohugoio/hugo", + // dir: cloneGithubProject(tb, benchRoot, "gohugoio", "hugo"), + // }, + // { + // name: "pact-foundation/pact-go", // CGO inside + // dir: cloneGithubProject(tb, benchRoot, "pact-foundation", "pact-go"), + // }, + // { + // name: "kubernetes/kubernetes", + // dir: cloneGithubProject(tb, benchRoot, "kubernetes", "kubernetes"), + // }, + // { + // name: "moby/buildkit", + // dir: cloneGithubProject(tb, benchRoot, "moby", "buildkit"), + // }, { name: "go source code", dir: filepath.Join(build.Default.GOROOT, "src"), @@ -392,7 +372,14 @@ func getLinterNames(tb testing.TB, fastOnly bool) []string { tb.Helper() // add linter names here if needed. - var excluded []string + excluded := []string{ + "gci", // Formatter + "gofmt", // Formatter + "gofumpt", // Formatter + "goimports", // Formatter + "golines", // Formatter + "swaggo", // Formatter + } linters, err := lintersdb.NewLinterBuilder().Build(config.NewDefault()) require.NoError(tb, err) @@ -403,6 +390,10 @@ func getLinterNames(tb testing.TB, fastOnly bool) []string { continue } + if lc.Internal { + continue + } + if fastOnly && lc.IsSlowLinter() { continue } diff --git a/test/run_test.go b/test/run_test.go index 7356575d1168..33630a89352e 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -279,7 +279,6 @@ func TestLineDirectiveProcessedFiles(t *testing.T) { }, target: "quicktemplate", expected: []string{ - "testdata/quicktemplate/hello.qtpl.go:10:1: package-comments: should have a package comment (revive)", "testdata/quicktemplate/hello.qtpl.go:26:1: exported: exported function StreamHello should have comment or be unexported (revive)", "testdata/quicktemplate/hello.qtpl.go:39:1: exported: exported function WriteHello should have comment or be unexported (revive)", "testdata/quicktemplate/hello.qtpl.go:50:1: exported: exported function Hello should have comment or be unexported (revive)", @@ -293,7 +292,6 @@ func TestLineDirectiveProcessedFiles(t *testing.T) { }, target: "quicktemplate", expected: []string{ - "testdata/quicktemplate/hello.qtpl.go:10:1: package-comments: should have a package comment (revive)", "testdata/quicktemplate/hello.qtpl.go:26:1: exported: exported function StreamHello should have comment or be unexported (revive)", "testdata/quicktemplate/hello.qtpl.go:39:1: exported: exported function WriteHello should have comment or be unexported (revive)", "testdata/quicktemplate/hello.qtpl.go:50:1: exported: exported function Hello should have comment or be unexported (revive)", diff --git a/test/testshared/integration/run.go b/test/testshared/integration/run.go index f1add865fb54..6bf33a3adc99 100644 --- a/test/testshared/integration/run.go +++ b/test/testshared/integration/run.go @@ -1,7 +1,6 @@ package integration import ( - "os" "os/exec" "path/filepath" "slices" @@ -32,12 +31,7 @@ func RunTestSourcesFromDir(t *testing.T, dir string) { binPath := testshared.InstallGolangciLint(t) - cwd, err := os.Getwd() - require.NoError(t, err) - t.Cleanup(func() { _ = os.Chdir(cwd) }) - - err = os.Chdir(dir) - require.NoError(t, err) + t.Chdir(dir) log := logutils.NewStderrLog(logutils.DebugKeyTest) log.SetLevel(logutils.LogLevelInfo)