Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/cmd/goimports: use of own package name creates broken imports #14073
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)