daixiang0 / gci

GCI, a tool that control golang package import order and make it always deterministic.
BSD 3-Clause "New" or "Revised" License
433 stars 62 forks source link

math/rand/v2 not considered as standard library #189

Closed tobischo closed 9 months ago

tobischo commented 9 months ago

What version of GCI are you using?

$ gci --version
gci version 0.12.3

Reproduce Steps

What did you expect to see?

I expected math/rand/v2 to be listed with the standard library packages and not with the other packages.

import (
  "database/sql"
  "math/rand/v2"
  "testing"
  "time"

  _ "github.com/lib/pq"
)

What did you see instead?

import (
  "database/sql"
  "testing"
  "time"

  _ "github.com/lib/pq"
  "math/rand/v2"
)
prochac commented 9 months ago

It may be built with old version, using old std lib

go version $(which gci)

try recompile it

tobischo commented 9 months ago
go version go1.22.0 linux/amd64

It was already compiled with go1.22.0. I had updated to the latest version to make sure that it wasn't that after I was already on go1.22.0.

prochac commented 9 months ago

I can't reproduce, even if I set module and toolchain to the previous version

➜  foo go run github.com/daixiang0/gci@latest write --custom-order -s=standard -s="Prefix(some.specific.domain.com/prefix)" -s=default --skip-generated --skip-vendor .
➜  foo cat main.go 
package main

import (
        "database/sql"
        "math/rand/v2"
        "testing"
        "time"

        _ "github.com/lib/pq"
)

func main() {}
➜  foo cat go.mod 
module foo.bar/baz

go 1.21

toolchain go1.21

require github.com/lib/pq v1.10.9
tobischo commented 9 months ago

I completely removed gci and re-installed it. Re-opened all shells etc to make sure that it should be in a close to fresh environment with go 1.22.

I cannot recreate it anymore either. So you might have been correct that it must still have been something somehow running against 1.21.

Closing this.

Thank you for checking and sorry for the additional work