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 <sam...@yandex.ru>
Date:   2016-04-04T09:09:07Z

    Put generated go code in a file with the same name as thrift file

commit f5ad756787e5150368ad66a7250b839de96263c0
Author: creker <sam...@yandex.ru>
Date:   2016-04-04T09:13:16Z

    Don't import self package, go doesn't support it

commit a00cc305f90dfca8594109bcd41697aa28f2ce0a
Author: creker <sam...@yandex.ru>
Date:   2016-04-04T09:29:14Z

    Rename UnusedProtection.go to GoUnusedProtection__.go to better separate it 
from real code

commit 5cbe8585383524bd4d3ecf7fe19d82a2c2a20994
Author: creker <sam...@yandex.ru>
Date:   2016-04-04T09:58:32Z

    Fix C++ compiler errors

commit e7a4ef1b54c3bb500aa41d349ff87cba1ffb0ef5
Author: creker <sam...@yandex.ru>
Date:   2016-04-04T12:20:03Z

    Don't put services in separate files

commit f426833156a3bc16f425d349c365961783c5afc4
Author: creker <sam...@yandex.ru>
Date:   2016-04-04T14:11:33Z

    Fix Go code generation when namespace is not specified

----


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to