An alternative Twirp server and client generator.
protoc-gen-twirp-go
generates clients and servers that are compatible with the
Twirp Wire Protocol Version 7.
protoc-gen-twirp-go
provides a place for experimentation in features and performance
while being compatible (by default) with the original Twirp clients and servers.
go get github.com/bakins/protoc-gen-twirp-go
You will also need:
- protoc, the protobuf compiler. You need version 3+.
- github.com/golang/protobuf/protoc-gen-go,
the Go protobuf generator plugin. Get this with
go get
. - The new protobuf Go generator is supported as well.
You can then use protoc-gen-twirp-go
just as you would protoc-gen-twirp
- you can even use them together:
protoc --go_out=. --twirp_out=. --twirp-go_out=. myservice.proto
For servers, the original Twirp creates a function called New<Service>Server
like NewHaberdasherServer
. protoc-gen-twirp-go
generates New<Service>TwirpServer
instead - NewHaberdasherTwirpServer
, for example.
For clients, he original Twirp creates two functions - one for json and one for protobuf.
protoc-gen-twirp-go
generates a single client function which is protobuf by default. To use
a json client, use:
client, err := NewHaberdasherTwirpClient(serviceURL, http.DefaultTransport, WithTwirpClientCodec(DefaultTwirpCodecJson))
protoc-gen-twirp-go
is a place for experimentation, however, we aim to maintain API compatibility between versions. Changes should be done via server and client options.
PR's and bug reports are welcome.
The code generated by this must be compatible by default with the original Twirp client and server wire protocol. If needed, this behavior can be changed with options.
see LICENSE