-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/go/ast/astutil: AddImport removes imports #17212
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
You want to fix? |
I'll take a stab at it, though I'm not yet familiar with manipulating the AST. Do you want to review? |
I'm scarred by and now scared of the AST package. I think @griesemer likes those CLs. :-) |
@bradfitz "likes" is a strong word. I prefer "unfortunately spent too much time with"... - I'll review it, but I cannot promise a quick turn-around as I am under water at the moment with other stuff. |
I've got a fix (https://golang.org/cl/29688), though I may have messed up the multi-commit workflow (it requires the change for #17213). I'd be happy to do them as a single commit, if that ends up being easier. |
CL https://golang.org/cl/29688 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?golang/tools@3f4088e
What operating system and processor architecture are you using (
go env
)?What did you do?
I added a test case to golang.org/x/tools/go/ast/astutil's imports_test.go for adding an import of
"net/http"
the following file:What did you expect to see?
I expected the output file to include all three imports, probably in a single import block.
What did you see instead?
It seems that this doesn't happen when the new package doesn't share a prefix with an existing package, or when the packages are all listed in a single block-style import.
The text was updated successfully, but these errors were encountered: