生成文件时保持目录结构
keep directory structure when generating files
我有那些 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
)
使用命名空间。在每个 IDL 文件顶部添加类似于以下内容的行:
namespace go a.a1 // whatever you need, but exactly one per IDL file
运行
thrift -r -gen go a1.thrift
在
下创建文件
gen-go/a/a1/*
我有那些 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
它输出:
./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
)
使用命名空间。在每个 IDL 文件顶部添加类似于以下内容的行:
namespace go a.a1 // whatever you need, but exactly one per IDL file
运行
thrift -r -gen go a1.thrift
在
下创建文件 gen-go/a/a1/*