drnf09037160 2017-04-28 09:25
浏览 189
已采纳

生成文件时保持目录结构

I have those thrift interfaces:

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

where a1.thrift includes a2, b1, b2 (with include "thrift/a/a2.thrift")

I generate the Go files for all those with thrift -r --gen go:package_prefix=work -I . --out . thrift/a/a1.thrift

It outputs:

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

How can I tell thrift to output in?

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

Note that I can move those files by hand but first I have many and second in Go the package has to match the directories, so I would need to edit those files. As an example the generated Go file for a1 will import a2 as work/a2 and not work/a/a2)

  • 写回答

1条回答 默认 最新

  • doulangbi6869 2017-04-28 10:32
    关注

    Use namespaces. Add a line similar to the following on top of each IDL file:

     namespace go a.a1   // whatever you need, but exactly one per IDL file
    

    Running

    thrift -r -gen go a1.thrift
    

    creates files under

     gen-go/a/a1/*
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持