github twitchtv/twirp v8.0.0
V8: Protobuf APIv2

latest releases: v8.1.3, v8.1.2, v8.1.1...
3 years ago

PR #304: Twirp v8 generates code that depends on Protobuf APIv2 (instead of APIv1).

Relevant links

Update Instructions

The runtime library github.com/twitchtv/twirp does not have any changes. The new generated code works with both old and new versions of the runtime library.

Re-generate code with Twirp v8 and Protobuf APIv2:

  • Install the new protoc-gen-go plugin: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest.
  • Install the new protoc-gen-twirp plugin: go install github.com/twitchtv/twirp/protoc-gen-twirp@latest.
  • Re-generate code. For example: protoc --go_out=paths=source_relative:. --twirp_out=paths=source_relative:. service.proto

See Install docs for more information.

Generated clients and services will use the new imports: google.golang.org/protobuf (APIv2). Projects that make use of the generated clients/servers will have to update their import paths.

The new google.golang.org/protobuf (APIv2) is mostly backwards compatible, but not completely. You may have to make additional changes to work with the new protobuf library:

  • In the proto file, the option go_package is mandatory and must include a "/" (it is supposed to be a full import path). If you have to add a full path to the go_package, you may want to generate with the options paths=source_relative. For example: protoc --go_out=. --go_opt=paths=source_relative --twirp_out=. --twirp_opt=paths=source_relative myfile.proto
  • Generated message models (structs) now contain a mutex, your linter may complain if the models are copied by value. The solution is to pass pointers instead. Using reflect.DeepEqual will not be able to compare protobuf, you can use proto.Equal instead.
  • Check protobuf go compatibility and their releases for more details.

Don't miss a new twirp release

NewReleases is sending notifications on new releases.