https://github.com/bakins/protoc-gen-twirp-go
An alternate Twirp Go client and server generator.
https://github.com/bakins/protoc-gen-twirp-go
go golang protobuf protoc twirp
Last synced: about 1 month ago
JSON representation
An alternate Twirp Go client and server generator.
- Host: GitHub
- URL: https://github.com/bakins/protoc-gen-twirp-go
- Owner: bakins
- License: apache-2.0
- Created: 2021-04-10T13:20:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-10T14:08:54.000Z (over 4 years ago)
- Last Synced: 2025-04-06T10:45:11.555Z (6 months ago)
- Topics: go, golang, protobuf, protoc, twirp
- Language: Go
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# protoc-gen-twirp-go
An alternative [Twirp](https://github.com/twitchtv/twirp) server and client generator.
`protoc-gen-twirp-go` generates clients and servers that are compatible with the
[Twirp Wire Protocol Version 7](https://twitchtv.github.io/twirp/docs/spec_v7.html).
`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.## Installation and Usage
```
go get github.com/bakins/protoc-gen-twirp-go
```You will also need:
- [protoc](https://github.com/protocolbuffers/protobuf), the protobuf compiler. You need
version 3+.
- [github.com/golang/protobuf/protoc-gen-go](https://github.com/golang/protobuf/),
the Go protobuf generator plugin. Get this with `go get`.
- The new [protobuf Go generator](https://github.com/protocolbuffers/protobuf-go) 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 `NewServer` like `NewHaberdasherServer`. `protoc-gen-twirp-go` generates `NewTwirpServer` 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))
```## Compatibility/Stability
`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.
## Contributing
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.## LICENSE
see [LICENSE](./LICENSE)