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
Comments
I wrote goimports once. I wouldn't say I own it. :) |
(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) |
I can take a stab at it, we'll see if it as easy a fix as I hope it is :) |
@ScottMansfield, are you working on it? If not, I would like to try to come up with a fix. |
@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. |
CL https://golang.org/cl/38191 mentions this issue. |
I think this was resolved in #30663. Please comment if you disagree. |
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)
The text was updated successfully, but these errors were encountered: