-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/bundle: does not recognize duplicate imports due to import aliases #37689
Comments
bundle can handle this edge-case better by deduplicating identical imports. When a given import path is loaded twice: import (
"same/import/path"
a "same/import/path"
) It would need to load the package with import path "same/import/path" and find out the package name. If the name the same, then one of those imports can be safely dropped. Note that the package name is not always equal to the last path element of its import path. For example: import (
"github.com/micro/go-micro"
micro "github.com/micro/go-micro"
) Those two imports are identical despite "micro" not being the same as the last import path element, and should still be deduplicated. However, it would be invalid to deduplicate two imports when the package name is different from the renamed one. |
@meling The best way would be to send a GitHub PR or Gerrit CL. Take a look at https://golang.org/doc/contribute.html#sending_a_change_github and https://golang.org/doc/contribute.html#sending_a_change_gerrit where the two options are described. Building on top of an existing CL should be more achievable via Gerrit. You can just rebase your commit on top of the commit corresponding to the existing CL, and |
Change https://golang.org/cl/222997 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Ran bundle (commit) on a package that contains both protobuf generated code and non-generated code. The generated code contains imports of the form:
Whereas the non-generated code have imports of the form:
What did you expect to see?
I would expect the imports to be rewritten as follows:
Or, alternatively:
What did you see instead?
Duplicate imports that cause compile error.
I have reported a companion issue here.
The text was updated successfully, but these errors were encountered: