0

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)

JensG
  • 13,148
  • 4
  • 45
  • 55
Thomas
  • 8,306
  • 8
  • 53
  • 92

1 Answers1

1

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/*
JensG
  • 13,148
  • 4
  • 45
  • 55