Thriftgo is an implementation of thrift compiler in go language. It has a command line interface similar to the apache/thrift compiler and is enhanced with a plugin mechanism which makes it more powerful.
Note: before executing the following commands, make sure your GOPATH
environment is properly set.
Using go install
:
GO111MODULE=on go install github.com/cloudwego/thriftgo@latest
Or build from source:
git clone https://github.com/cloudwego/thriftgo.git
cd thriftgo
export GO111MODULE=on
go mod tidy
go build
go install
The Thriftgo command line tool accepts IDL files and compiles them to the target language. Each backend has a plentiful set of options to customize the generated code.
By the moment, Thriftgo can generates golang code only. More backends will be added in the future.
To compile an thrift IDL to golang files with the default setting, you can just run:
thriftgo -g go the-idl-file.thrift
Run thriftgo -h
to see all available options for each backend and their meanings.
If the code generated by Thriftgo does not satisfy your needs and the options provideds do not meet your requirements. You may also write plugins to generate code beside Thriftgo while taking the advantage of Thriftgo's IDL parser. Check the documentation of the plugin package for more details.