GitHub user creker opened a pull request:
https://github.com/apache/thrift/pull/974
Generate go code from multiple thrift files in to the same directory
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. First commit lets compiler put generated Go code into the files with the
same names as original thrift files. That's mimics behaviour of other language
generators. Types 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. Second commit prevents 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
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---