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

Open
ScottMansfield opened this issue Jan 22, 2016 · 7 comments

Comments

@ScottMansfield
Copy link

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

This comment has been minimized.

Copy link
Contributor

commented Feb 3, 2016

Brad owns goimports. The feature seems reasonable though.

cc: @bradfitz, @crawshaw

@bradfitz

This comment has been minimized.

Copy link
Member

commented Feb 3, 2016

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

@bradfitz bradfitz removed their assignment Feb 3, 2016

@bradfitz

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2017

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

@ScottMansfield

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

commented Mar 15, 2017

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

@gopherbot gopherbot added the Tools label Sep 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.