I generally tend to use buf rather than directly calling protoc, so I had to do a bit of work to figure out how to make this work with that.
Here's my solution:
buf.yaml
version: v2
modules:
- path: proto
buf.gen.yaml
version: v2
clean: true
managed:
enabled: true
plugins:
- local: ["go", "tool", "github.com/knqyf263/go-plugin/cmd/protoc-gen-go-plugin"]
out: pkg
opt:
- paths=source_relative
strategy: directory
include_imports: true
include_wkt: true
And added the following to my go.mod (making use of the new tool directive):
tool (
github.com/bufbuild/buf/cmd/buf
github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking
github.com/bufbuild/buf/cmd/protoc-gen-buf-lint
github.com/knqyf263/go-plugin/cmd/protoc-gen-go-plugin
)
I can now run:
And have it generate the code from my proto folder into my pkg folder.
I generally tend to use buf rather than directly calling
protoc, so I had to do a bit of work to figure out how to make this work with that.Here's my solution:
buf.yamlbuf.gen.yamlAnd added the following to my
go.mod(making use of the new tool directive):I can now run:
And have it generate the code from my
protofolder into mypkgfolder.