[ 
https://issues.apache.org/jira/browse/THRIFT-4685?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17246680#comment-17246680
 ] 

Yuxuan Wang edited comment on THRIFT-4685 at 12/9/20, 5:17 PM:
---------------------------------------------------------------

[~slon] Thanks. I understood the situation.

If the only problem is that your codebase needs to import 2 different versions 
of thrift library, one from your dependency and one for yourself, one 
+workaround+ you can do is to use 
["git.apache.org/thrift.git/lib/go/thrift"|https://pkg.go.dev/git.apache.org/thrift.git@v0.13.0/lib/go/thrift]
 for the one for yourself. You can pass the thrift_import flag to thrift 
compiler to make sure that thrift compiled go file also use this import path:

{noformat}
thrift_import=   Override thrift package import path 
(default:github.com/apache/thrift/lib/go/thrift)
{noformat}

Of course that's just a workaround. It won't work if you actually need 3 or 
more versions to co-exist, git.apache.org/thrift.git might disappear/sunset in 
the future, etc.. But have you tried that? Although go's toolchain allows you 
to have 2 versions of the same library to co-exist as long as they have 
different import paths, in reality consider thrift's unique case of compiler 
get mixed in, I suspect that you will actually face other issues causing them 
to not able to co-exist at all. If "github.com/apache/thrift/lib/go/thrift" 
from your dependency and "git.apache.org/thrift.git/lib/go/thrift" from your 
other code cannot really co-exist in your project, then 
"github.com/apache/thrift/lib/go/thrift/vN" (or maybe 
"github.com/apache/thrift/vN/lib/go/thrift", I haven't tried to see which is 
actually accepted by go toolchain) won't co-exist either, so changing the major 
version won't really help your case.

The real solution really should be for those third party libraries to update 
their thrift dependency. [0.9.3 is 5 year old 
now|https://github.com/apache/thrift/releases/tag/0.9.3]. tchannel-go says they 
don't want to do breaking changes in v1, that's fine and a valid point. But 
"don't want to bump to v2 in order to update a 5 year old dependency" really is 
not.


was (Author: fishywang):
[~slon] Thanks. I understood the situation.

If the only problem is that your codebase needs to import 2 different versions 
of thrift library, one from your dependency and one for yourself, one 
+workaround+ you can do is to use 
["git.apache.org/thrift.git/lib/go/thrift"|https://pkg.go.dev/git.apache.org/thrift.git@v0.13.0/lib/go/thrift]
 for the one for yourself. You can pass the thrift_import flag to thrift 
compiler to make sure that thrift compiled go file also use this import path:

{noformat}
thrift_import=   Override thrift package import path 
(default:github.com/apache/thrift/lib/go/thrift)
{noformat}

Of course that's just a workaround. It won't work if you actually need 3 or 
more versions to co-exist, git.apache.org/thrift.git might disappear/sunset in 
the future, etc.. But have you tried that? Although go's toolchain allows you 
to have 2 versions of the same library to co-exist as long as they have 
different import paths, in reality consider thrift's unique case of compiler 
get mixed in, I suspect that you will actually face other issues causing them 
to not able to co-exist at all. If "github.com/apache/thrift/lib/go/thrift" 
from your dependency and "git.apache.org/thrift.git/lib/go/thrift" from your 
other code cannot really co-exist in your project, then 
"github.com/apache/thrift/lib/go/thrift/vN" (or maybe 
"github.com/apache/thrift/vN/lib/go/thrift", I haven't tried to see which is 
actually accepted by go toolchain) won't co-exist either, so changing the major 
version won't really help your case.

> Support the new golang modules (1.11 or later)
> ----------------------------------------------
>
>                 Key: THRIFT-4685
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4685
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Go - Library
>    Affects Versions: 0.12.0
>         Environment: golang 1.11 or later
>            Reporter: James E. King III
>            Assignee: Duru Can Celasun
>            Priority: Minor
>
> Go added new module support in 1.11, see:
> https://github.com/golang/go/wiki/Modules
> We should move towards it.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to