Skip to content

x/tools/goimports BUG: extra blank line after formatting #53997

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

Closed
ban11111 opened this issue Jul 22, 2022 · 2 comments
Closed

x/tools/goimports BUG: extra blank line after formatting #53997

ban11111 opened this issue Jul 22, 2022 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ban11111
Copy link

ban11111 commented Jul 22, 2022

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

 golang.org/x/tools  v0.1.11

Does this issue reproduce with the latest release?

yes

What did you do?

for example, when there are:

import (
    "golang.org/x/tools/imports"
    "testing"
    "fmt"

    "github.com/xx/yy"
    "github.com/aa/bb"
)

simply run goimports formating the file

What did you expect to see?

after formatting:

import (
    "fmt
    "testing"

    "github.com/xx/yy"
    "github.com/aa/bb"
    "golang.org/x/tools/imports"
)

What did you see instead?

after formatting:

import (
    "fmt
    "testing"

    "golang.org/x/tools/imports"

    "github.com/xx/yy"
    "github.com/aa/bb"
)
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jul 22, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jul 22, 2022
@ban11111 ban11111 changed the title x/tools/goimports BUG x/tools/goimports BUG: extra blank line after formatting Jul 22, 2022
@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 22, 2022
@rsc
Copy link
Contributor

rsc commented Jul 22, 2022

I don't believe this is a bug. There is no rule that imports should only have at most two blocks. Goimports moves non-std imports out of the std section, but it does not (nor should it) presume that they belong in some other existing section. Instead it creates a new one.

@seankhliao
Copy link
Member

Duplicate of #20818

@seankhliao seankhliao marked this as a duplicate of #20818 Jul 22, 2022
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2022
@golang golang locked and limited conversation to collaborators Jul 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants