-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/cmd/goimports: doesn't handle packages named "v1", etc #29041
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
Comments
I see this with the head of |
Don't name your packages |
Yeah this blows up on anything touching K8s :P |
Was this caused by https://go-review.googlesource.com/122616? (golang/tools@893c2b1) Curious whether/how people think we should fix this. @rsc @heschik @bcmills @dmitshur @kevinburke @Gnouc @josharian @mvdan @fraenkel @haya14busa |
See also #28435. |
If We can compute the set of “names that might be package names” in an O(N) scan over the source file. |
As a workaround, what happens if you rename the package explicitly on import? That is, change import (
"k8s.io/api/core/v1"
) to import (
v1 "k8s.io/api/core/v1"
) ? |
I haven't looked at this closely but I believe Bryan's suggestion will fix it, and my fix for #28428 will add the v1 automatically. |
Give https://golang.org/cl/152000 a try? |
Confirmed that tip goimports now adds the v1 name to the import rather than deleting it. |
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
There are 3 types of errors fixed: a. one empty line is required before where third-party pkgs imports b. packages can have dashes in import path but won't have in name[1], explicitly name them on import. c. packages that are just version numbers like "v1" need explicit naming too[2]. [1] golang/go#17546 [2] golang/go#29041 Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
There are 3 types of errors fixed: a. one empty line is required before where third-party pkgs imports b. packages can have dashes in import path but won't have in name[1], explicitly name them on import. c. packages that are just version numbers like "v1" need explicit naming too[2]. [1] golang/go#17546 [2] golang/go#29041 Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
golang/go#29041 This is a slightly counterintuitive workaround for the above bug. The alternative to this commit would be to disable goimports linting until the bug is fixed. I think it's worth the workaround for the time being in exchange for the value goimports linting brings. Signed-off-by: Nic Cope <negz@rk0n.org>
What version of Go are you using (
go version
)?I'm seeing a bad format with goimports at commit: 1c3d964
You can see the bad formatting turned into a PR here: knative/pkg#176
The comment run is what's in the PR description (minus the
-s
, it's WIP).cc @bradfitz
The text was updated successfully, but these errors were encountered: