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: use of own package name creates broken imports #14073

Closed
ScottMansfield opened this issue Jan 22, 2016 · 8 comments
Closed
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ScottMansfield
Copy link

When running goimports on a file in a package that (wrongly) uses it's own name as a qualifier, goimports will rewrite the imports to include the code file's own package in the imports. Goimports shows no error and only on compilation will there be an import cycle error.

I propose that Instead of the imports being rewritten, a check be performed to see if the file is in the same package as goimports is trying to add. If this situation is detected, the command should fail and output an error message instead of rewriting.

I'll be working on patching this behavior if this proposal sounds appropriate.

cc: @alandonovan (since I think you're the one to ask)

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Jan 22, 2016
@alandonovan
Copy link
Contributor

Brad owns goimports. The feature seems reasonable though.

cc: @bradfitz, @crawshaw

@bradfitz
Copy link
Contributor

bradfitz commented Feb 3, 2016

I wrote goimports once. I wouldn't say I own it. :)

@bradfitz bradfitz removed their assignment Feb 3, 2016
@bradfitz
Copy link
Contributor

bradfitz commented Feb 3, 2016

(I unassigned it so anybody can feel free to fix. I don't want to give the impression that I'm actively working on or planning on working on this)

@ScottMansfield
Copy link
Author

I can take a stab at it, we'll see if it as easy a fix as I hope it is :)

@davidrjenni
Copy link
Contributor

@ScottMansfield, are you working on it? If not, I would like to try to come up with a fix.

@ScottMansfield
Copy link
Author

@davidrjenni Nope, I never did get around to it. By all means, please go ahead. This bit me again recently, but it turned out to be not as much of a nuisance in the mean time so I forgot about it.

@gopherbot
Copy link

CL https://golang.org/cl/38191 mentions this issue.

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
@heschi
Copy link
Contributor

heschi commented Nov 7, 2019

I think this was resolved in #30663. Please comment if you disagree.

@heschi heschi closed this as completed Nov 7, 2019
@golang golang locked and limited conversation to collaborators Nov 6, 2020
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

7 participants