[
https://issues.apache.org/jira/browse/THRIFT-3776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15224361#comment-15224361
]
ASF GitHub Bot commented on THRIFT-3776:
----------------------------------------
GitHub user creker reopened a pull request:
https://github.com/apache/thrift/pull/974
THRIFT-3776 Go code from multiple thrift files with the same namespace
Currently compiler puts all generated Go code into two files - ttypes.go
and constants.go. Because of that you can't compile multiple thrift files with
the same namespace. They will just overwrite each other.
This PR fixes two things that closely related to each other:
1) Allow compiler to put generated Go code into the files with the same
names as original thrift files. That mimics behaviour of other language
generators. Types and services will be put into [thrift file name].go and
constants will be put into [thrift file name]-consts.go. As a bonus, if you put
everything into one file result will be basically the same as before.
The only difference is I put GoUnusedProtection__ variable into it's own
.go file to prevent redefinition.
2) Prevent importing self package. Before this compiler would put self
package into import section which Go doesn't support. Now compiler will
recognize that types are from the same namespace. Without this you can't
generate working Go code from multiple thrift files.
This PR doesn't add new compiler flag for this.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/creker/thrift GoMultiFileCompiler
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/974.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #974
----
commit 06e73e2753ba8df7a4a6172f21cd14a80d9023a4
Author: creker <[email protected]>
Date: 2016-04-04T09:09:07Z
Put generated go code in a file with the same name as thrift file
commit f5ad756787e5150368ad66a7250b839de96263c0
Author: creker <[email protected]>
Date: 2016-04-04T09:13:16Z
Don't import self package, go doesn't support it
commit a00cc305f90dfca8594109bcd41697aa28f2ce0a
Author: creker <[email protected]>
Date: 2016-04-04T09:29:14Z
Rename UnusedProtection.go to GoUnusedProtection__.go to better separate it
from real code
commit 5cbe8585383524bd4d3ecf7fe19d82a2c2a20994
Author: creker <[email protected]>
Date: 2016-04-04T09:58:32Z
Fix C++ compiler errors
commit e7a4ef1b54c3bb500aa41d349ff87cba1ffb0ef5
Author: creker <[email protected]>
Date: 2016-04-04T12:20:03Z
Don't put services in separate files
commit f426833156a3bc16f425d349c365961783c5afc4
Author: creker <[email protected]>
Date: 2016-04-04T14:11:33Z
Fix Go code generation when namespace is not specified
----
> Go code from multiple thrift files with the same namespace
> ----------------------------------------------------------
>
> Key: THRIFT-3776
> URL: https://issues.apache.org/jira/browse/THRIFT-3776
> Project: Thrift
> Issue Type: Improvement
> Components: Go - Compiler
> Affects Versions: 0.9.3
> Reporter: artem antonenko
>
> Currently compiler puts all generated Go code into two files - ttypes.go and
> constants.go. Because of that you can't compile multiple thrift files with
> the same namespace. They will just overwrite each other.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)