生成文件时保留目录结构

时间:2017-04-28 09:25:22

标签: go thrift

我有那些节俭接口:

./thrift/a/a1.thrift
./thrift/a/a2.thrift
./thrift/b/b1.thrift
./thrift/b/b2.thrift

其中a1.thrift包含a2,b1,b2(带include "thrift/a/a2.thrift"

我为thrift -r --gen go:package_prefix=work -I . --out . thrift/a/a1.thrift

的所有人生成了Go文件

输出:

./a1/constants.go
./a1/ttypes.go
./a2/...
./b1/...
./b2/...

如何告诉thrift输出?

./a/a1/...
./a/a2/...
./b/b1/...
./b/b2/...

请注意,我可以手动移动这些文件,但首先我在Go 中有许多和第二个文件包必须匹配目录,所以我需要编辑这些文件。例如,为a1生成的Go文件将导入a2为work/a2而不是work/a/a2

1 个答案:

答案 0 :(得分:1)

使用名称空间。在每个IDL文件的顶部添加类似于以下内容的行:

thrift -r -gen go a1.thrift

运行

 gen-go/a/a1/*

下创建文件
More