So I have the following files
/src/baseService.thrift
/baseTypes.thrift
/baseSecurity.thrift
I want all of these thrift definitions to be created into one library. The top of each file is thus:
baseService.thrift
==================
namespace java foo.bar
namespace cpp foo.bar
namespace js foo.bar
namespace go foo.bar
import "baseTypes.thrift"
baseTypes.thrift
================
namespace java foo.bar
namespace cpp foo.bar
namespace js foo.bar
namespace go foo.bar
baseSecurity.thrift
===================
namespace java foo.bar
namespace cpp foo.bar
namespace js foo.bar
namespace go foo.bar
import "baseTypes.thrift"
The problem is, how to I create all of these into one lib package? It works fine for java/cpp/js but when I try to build for go it's a no go.
With thrift, you can't do a thrift gen:baz *.thrift
, you have to do the files one at a time. For the other languages, we just do a:
for f in `find *.thrift`; do
thrift -o myGenDir --gen go $f"
done
(substitute appropriate gen command for each lang)
For Python this is fine because it puts every gen'd file in it's own dir based on the filename [ i.e. foo/bar/{filename}/ttypes.py]. For Java it dumps all of the files in foo/bar/ but every class name is unique. For cpp, it dumps it all into the gen dir, but uniquely named per thrift file [so {filename.h}, {filename.cpp}]. For Go, however, it dumps everything into foo/bar like so:
/foo/bar/constants.go
/foo/bar/service.go
/foo/bar/service-remote/
/foo/bar/baz/ [for anything that has a namespace of foo.bar.baz]
/foo/bar/ttypes.go
The problem is, the ttypes.go and (presumably) constants.go are getting overwritten by whatever is gen'd last in the for loop. Is there a way around this? It works for the other languages - seems like it's an oversight for Go. What am I missing. We've got lots of Thrift files with lots of stuff in them - I'd rather not have to combine everything that's at the same package level into one thrift file.