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: incorrectly adds imports for variables that match package names #13023
Comments
I think we're probably going to have to chalk this up to heuristic failure, but if somebody can figure out a good fix, by all means go for it. |
In my case, an option to reorder imports but not add new ones would do. |
@cep21 gofmt reorders imports without adding/removing them. Does that do what you want? |
I don't currently see that behavior in go1.5.1. Is it new? |
I don't think so. These cmd/gofmt test files haven't changed in 2+ years: https://github.com/golang/go/blob/master/src/cmd/gofmt/testdata/import.input |
I don't observe gofmt reordering imports like goimports
|
Ah, I suppose gofmt doesn't separate stdlib imports from third-party imports like goimports does. If you separate them yourself, it should still sort contiguous runs of imports. |
@ianlancetaylor Maybe goimports could run go/types on the AST and only consider |
Dup of #7463 |
Please see the following console output as a test case.
log
is a varaible defined in another file and therefor does not need a package import. The expected behavior is for goimports to detect no issues.The text was updated successfully, but these errors were encountered: