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
Milestone

Comments

@ScottMansfield
Copy link

@ScottMansfield ScottMansfield commented Jan 22, 2016

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

@alandonovan alandonovan commented Feb 3, 2016

Brad owns goimports. The feature seems reasonable though.

cc: @bradfitz, @crawshaw

@bradfitz
Copy link
Contributor

@bradfitz 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 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

@ScottMansfield ScottMansfield commented Feb 3, 2016

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

@davidrjenni davidrjenni commented Mar 10, 2017

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

@ScottMansfield
Copy link
Author

@ScottMansfield ScottMansfield commented Mar 10, 2017

@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

@gopherbot gopherbot commented Mar 15, 2017

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

@gopherbot gopherbot added the Tools label Sep 12, 2019
@heschik
Copy link
Contributor

@heschik heschik commented Nov 7, 2019

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

@heschik heschik closed this Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.