Download Latest Version v8.1.3 source code.tar.gz (917.7 kB)
Email in envelope

Get an email when there's a new version of Twirp

Home / v8.0.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2021-05-03 2.4 kB
V8_ Protobuf APIv2 source code.tar.gz 2021-05-03 916.7 kB
V8_ Protobuf APIv2 source code.zip 2021-05-03 1.3 MB
Totals: 3 Items   2.2 MB 0

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

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.
Source: README.md, updated 2021-05-03