-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: fails to distinguish package from global variable #7463
Comments
goimports works on a file-by-file basis like gofmt; and as such it does not and cannot know that file a.go and b.go belong to the same package. Put another way, this is a user error for the tool as is. Leaving to bradfitz to decide whether to close or convert to a feature request. Owner changed to @bradfitz. |
Comment 6 by [email protected]: > Seems rare enough. I use this idiom in most of my packages as well |
I'm hitting the same issue here.. exactly with that Also, not recognizing the global var massively slows down |
When working with such a package, goimports actually becomes a hinderance, because it adds unwanted things that then need to be fixed manually, on each run. I understand we want to keep goimports work on a single file.. could we annotate things, then ? (not a superb solution either.. bbbuuuttt! :) |
Well, |
I must say that this happens only some times. I have a package with multiple files. One file has the famous For months I didn't hit this bug, but today it started to happen in one file only. |
Probably you have used some other fields/methods on your log variable which helps goimports to distinguish between correct and wrong log packages, but this has change and now you're using only fields/methods compatible with standard log package in this file, so this changed goimports result. |
Spot on. Anyway, I solved the issue changing the variable name from |
proposed fix https://go-review.googlesource.com/23444 |
CL https://golang.org/cl/23444 mentions this issue. |
CL https://golang.org/cl/25140 mentions this issue. |
Updates dominikh/go-mode.el#146 Updates golang/go#7463 (for https://golang.org/cl/23444) Change-Id: Ieb769329531050b803528acce0c50d02786533b6 Reviewed-on: https://go-review.googlesource.com/25140 Reviewed-by: Alan Donovan <[email protected]>
by peterbourgon:
The text was updated successfully, but these errors were encountered: