Using remote plugins
Buf's remote plugins remove a key obstacle to generating code—plugins are developed across many languages, and manual installation is inconsistent as a result. Instead of wasting your time maintaining plugins for yourself or your organization, you can reference commonly-used plugins hosted in the Buf Schema Registry (BSR). For example:
version: v2
plugins:
- remote: buf.build/protocolbuffers/go:v1.31.0 # Use protoc-gen-go at v1.31.0
out: gen/go
opt: paths=source_relative
- remote: buf.build/grpc/go # Use the latest version of protoc-gen-go-grpc
out: gen/go
opt: paths=source_relative
Note
If you don't specify a plugin version, the latest version will be pulled in. To avoid unexpected updates and possible breaking changes, pin to a specific version.
To browse all publicly-available plugins, go to buf.build/plugins.
Plugin catalog in the BSR
The plugins are organized in the BSR by language.
When you click through to a given plugin, the BSR provides a sample of how to invoke the plugin in your buf.gen.yaml
file, and the necessary code to add any other plugins that it depends on.
Choose the sample that matches the Buf version used in your configuration files.
Choosing a version and revision number will give you code that pins to that version and revision. Otherwise, the sample code defaults to an invocation that will give you the latest version.
- The plugin version is specified by the upstream project.
- The revision is a sequence number that Buf increments when rebuilding or repackaging the plugin.
Note
If you'd like a Protobuf plugin to be added to the Buf Schema Registry, open an issue and our team will follow up.
Related docs
- Try out code generation with the
buf generate
tutorial - Browse the
buf generate
reference and thebuf.gen.yaml
reference - Find out how to create custom plugins for your organization