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

x/tools/cmd/goimports doesn't reorder standard library imports if they're already in separate blocks #50446

Closed
DylanSpOddball opened this issue Jan 5, 2022 · 1 comment
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@DylanSpOddball
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.17.5 linux/amd64

Does this issue reproduce with the latest release?

Yes (1.17.5 is the latest release, as of filing this issue)

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dylan/.cache/go-build"
GOENV="/home/dylan/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/dylan/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/dylan/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3462334434=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Use goimports to reorder imports, expecting to see standard library dependencies placed above other dependencies.

main.go:

import (
    _ "github.com/google/uuid"

    _ "time"
)

Command run: goimports main.go

What did you expect to see?

I expected to see

import (
    _ "time"

    _ "github.com/google/uuid"
)

following the convention that standard library imports are placed first. (This convention is followed by goimports when stdlib dependencies are mixed in with another block, as well as being mentioned on GitHub at https://github.com/golang/go/wiki/CodeReviewComments#imports)

What did you see instead?

No changes:

$ goimports main.go
import (
        _ "github.com/google/uuid"

        _ "time"
)

Other notes

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jan 5, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jan 5, 2022
@DylanSpOddball DylanSpOddball changed the title x/tools/cmd/goimports x/tools/cmd/goimports doesn't reorder standard library imports if they're already in separate blocks Jan 5, 2022
@seankhliao
Copy link
Member

Duplicate of #20818

@seankhliao seankhliao marked this as a duplicate of #20818 Jan 5, 2022
@golang golang locked and limited conversation to collaborators Jan 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants