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/import: bug with work across multiple import sections #26795

Closed
ewgRa opened this issue Aug 3, 2018 · 1 comment
Closed

x/tools/import: bug with work across multiple import sections #26795

ewgRa opened this issue Aug 3, 2018 · 1 comment

Comments

@ewgRa
Copy link

ewgRa commented Aug 3, 2018

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

1.9.2

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

amd64

What did you do?

I run goimports on this code: https://play.golang.org/p/hwfKtMHlwmD

What did you expect to see?

I want to see that goimports suggest to change code like this: https://play.golang.org/p/R7QEiX-e8io
Group local imports in several sections to one import section.

What did you see instead?

goimport do not to suggest any changes
Is it a feature or a bug?

@agnivade
Copy link
Contributor

Hello @ewgRa, please see @rsc's comment here #26846 (comment).

We intentionally leave this to local custom - gofmt and goimports will never move imports across blank lines in the import block. So if I want path with the others, I can do that, and gofmt/goimports respect that. And if you want all your renamed imports together, you can do that, and gofmt/goimports respect that too.

i.e. imports separated by blank lines are considered separate and that is intentional. Hence gofmt/goimports will not dedup entries beyond a single import group.

Your issue is a much bigger extension of that, which is merging imports across multiple import sections. Applying the same logic above, I would say this is a feature and not a bug. I am going to close this now. Please feel free to comment if you think this was a mistake.

@golang golang locked and limited conversation to collaborators Aug 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants