[
https://issues.apache.org/jira/browse/THRIFT-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16863531#comment-16863531
]
John Boiles commented on THRIFT-4797:
-------------------------------------
I've got a fix [here|https://github.com/apache/thrift/pull/1811]. In short, it
looks to see if there's going to be a collision in the imports, and if there
is, the compiler creates an alias by appending a number with {{tmp}}. It
generates code like this:
{code:go}
import (
"packagea/common"
common0 "packageb/common"
common1 "common"
)
{code}
As a future improvement, it'd be nicer to instead concatenate as many path
components as necessary to generate a more human readable endpoint
{code:go}
import (
conflictacommon "conflicta/common"
conflictbcommon "conflictb/common"
"common"
)
{code}
But that looks like it has some tricks. We'd need to first start with the
simplest imports (in this example {{common}}), and allow them to lay claim the
their name, then go through more complex imports (in this example
{{conflicta/common}}) and disambiguate.
> Generated Go code produces name collisions on imports
> -----------------------------------------------------
>
> Key: THRIFT-4797
> URL: https://issues.apache.org/jira/browse/THRIFT-4797
> Project: Thrift
> Issue Type: Bug
> Components: Go - Compiler
> Affects Versions: 0.12.0
> Reporter: Josh Yudaken
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> If two modules have the same name, the produced go code will not compile.
> For example:
> {code:java}
> import (
> "github.com/sample/project/common"
> "github.com/different/thing/common"
> ){code}
> In go the final component (commons) is used as the name so there is a
> collision.
> This can be fixed by aliasing the modules
> {code:java}
> import (
> common_1 "github.com/sample/project/common"
> common_2 "github.com/different/thing/common"
> ){code}
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)