Plugin request for Buf Schema Registry: protopatch
Closed this issue · 3 comments
This plugin allows to wrap calls of code generators and patch them before writing. This allows users to circumvent most syntax issues that come with using protobuf and Go code generation. For example, item_id
is parsed to ItemId
instead ItemID
as per Go's style guide.
Another glaring issue is enum types which generate horrendous Go types as follows:
enum EnumExample {
ENUM_EXAMPLE_UNSPECIFIED = 0;
...
}
Which is compiled as EnumExample_ENUM_EXAMPLE_UNSPECIFIED
.
Both of these issues and other ugly syntax issues can be solved with this plugin. The plugin is actively maintained and would be a great addition to the buf ecosystem.
Mandatory
Where is the source code for the plugin?
https://github.com/alta/protopatch
Optional
Does the plugin have a valid semver version?
v0.5.3
Thanks for filing an issue. I'm afraid this plugin won't work as a Remote Plugin because it shells out other protoc-gen-*
plugins.
It's a neat plugin, but it's best run locally.
ps. For the enum issue, that should be solved in the generator itself (at least with an opt-in option to maintain compatibility). There's an issue to track this golang/protobuf#513
It would still be nice to have a BSR repo. Usage requires import "patch/go.proto";
, which has to be made available with buf.yaml->modules->path or buf.yaml->deps. A github repo or installed go package can't be used for either.
I was able to get it working by replacing
- local: protoc-gen-go
out: gen
opt: paths=source_relative
with
- local: protoc-gen-go-patch
out: gen
opt:
- paths=source_relative
- plugin=go
and adding /proto/patch/go.proto to my project. Looks like someone else made their own BSR repo for this: https://buf.build/nvxx/protopatch/tree/main
Edit:
I've added https://github.com/Landeed/protopatch and https://buf.build/landeed/protopatch so this works:
deps:
- buf.build/landeed/protopatch
Just don't forget to buf dep update
.
Hi, author of protopatch. I'm happy to help with necessary integrations if folks want to use it with Buf.