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: removes necessary imports with certain characters #29044
Comments
Hi @mattmoor - Could you provide us with a self-contained code sample which reproduces this behavior ? I tried this myself but wasn't able to reproduce it.
I believe that is a different issue than this, right ? Is there a reason you cannot use the tip /cc @bradfitz EDIT: I also have github.com/aws/aws-sdk-go throughout several codebases, and goimports work fine there. Trying to understand if there is a regression somewhere or this was fixed. |
Weird, so I cannot reproduce this when |
Steps:
|
I just tried with HEAD (d0ca393) and I am still unable to reproduce it.
Could you please attach the output of |
Yeah. In general, if a package's name doesn't match its import path, goimports is going to have to load it. In GOPATH mode, that means having it on GOPATH. tip goimports now adds a name to the import in these situations, which prevents the problem.
@agnivade: you probably had a copy of the package in your GOPATH already when you ran goimports. I don't think there's anything we can do to improve the situation further, so I'm closing this. Comment if you disagree. |
@heschik I worked around this by symlinking the repo onto GOPATH. I will try tip when I get a chance. thanks. |
Using
goimports
atrelease-branch.go1.10
, I see it dropping necessary imports when they have-
and are not aliased,You can see it in this removal with a hyphen:
https://github.com/knative/eventing/pull/653/files#diff-abdff22f055e921908e64cdb584fa75cL25
... and this removal with a dot:
https://github.com/knative/docs/pull/611/files#diff-06a9a211281c9004b5638fc5207899d8L32
I can't use HEAD or 1.11 because of: #29041
The text was updated successfully, but these errors were encountered: