golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.55k stars 1.38k forks source link

GCI chokes on math/rand/v2 #4415

Closed andig closed 7 months ago

andig commented 7 months ago

Welcome

Description of the problem

Importing math/rand/v2, GCI wants the import in the second, no-standard-library, import block which is wrong:

  Running [/home/runner/golangci-lint-1.56.2-linux-amd64/golangci-lint run --out-format=colored-line-number,github-actions --timeout 5m] in [] ...
  provider/mqtt/client.go:6: File is not `gci`-ed with --skip-generated -s standard -s default (gci)
    "math/rand/v2"
  provider/mqtt/client.go:15: File is not `gci`-ed with --skip-generated -s standard -s default (gci)
    "github.com/evcc-io/evcc/util/request"
  hems/ocpp/ocpp.go:5: File is not `gci`-ed with --skip-generated -s standard -s default (gci)
    "math/rand/v2"
  Error: File is not `gci`-ed with --skip-generated -s standard -s default (gci)
  Error: File is not `gci`-ed with --skip-generated -s standard -s default (gci)
  Error: File is not `gci`-ed with --skip-generated -s standard -s default (gci)

Running with --fix produces imports like:

    "fmt"
    "strings"
    "time"

    "github.com/evcc-io/evcc/api"
    "github.com/evcc-io/evcc/core/site"
    "github.com/evcc-io/evcc/hems/ocpp/profile"
    "github.com/evcc-io/evcc/util"
    "github.com/evcc-io/evcc/util/machine"
    ocpp16 "github.com/lorenzodonini/ocpp-go/ocpp1.6"
    ocppcore "github.com/lorenzodonini/ocpp-go/ocpp1.6/core"
    "github.com/lorenzodonini/ocpp-go/ws"
    "math/rand/v2" // <-- doesn't belong there

Reproed locally, so not depending on action.

Version of golangci-lint

```console $ golangci-lint --version golangci-lint has version 1.56.2 built with go1.22.0 from 58a724a on 2024-02-15T12:52:06Z ```

Configuration

.

Go environment

```console $ go version && go env go version go1.22.0 darwin/arm64 GO111MODULE='' GOARCH='arm64' GOBIN='' GOCACHE='/Users/andig/Library/Caches/go-build' GOENV='/Users/andig/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/andig/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/andig/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/opt/homebrew/Cellar/go/1.22.0/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.0/libexec/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.22.0' GCCGO='gccgo' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOMOD='/Users/andig/htdocs/evcc/go.mod' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build1340198295=/tmp/go-build -gno-record-gcc-switches -fno-common' ```

Verbose output of running

```console $ golangci-lint cache clean $ golangci-lint run -v # paste output here ```

A minimal reproducible example or link to a public repository

https://github.com/evcc-io/evcc/commit/ad0c6d5eb1363e2ba554c3bbb30aac07798171f9

Validation

andig commented 7 months ago

Please hold. Didn't notice that GCI is an independent linter.

andig commented 7 months ago

Note: this is fixed in https://github.com/daixiang0/gci/pull/186

ldez commented 7 months ago

Fixed by #4400

andig commented 7 months ago

Thank you very much.

fatedier commented 7 months ago

Need a new release for this.