I am testing grpc-gateway and trying to figure out the best way to import dependencies in my grpc service. I have the following dir structure:
proto/
api.proto
api2.proto
third_party/
googleapis/
google/
api/
http.proto
annotations.proto
buf.yaml
buf.gen.yaml
buf.yaml config
version: v1beta1
build:
roots:
- third_party/googleapis
- third_party/grpc-gateway
- proto
Two things
- As you noticed I am using buf.build to generate proto files (you can ignore this fact if you know a better way);
- I am not copying
googleapi
under proto files intentionally and would like to keep them separate somewhere. I know google recommends keeping everything underproto
folder and just copying dependent files (likegoogle/api/annotations.proto
), but I am not a fan of copying dozens of dependencies into my source code if I can avoid that somehow.
My question is, whenever I run buf generate --path=./proto
(please notice path is set as a directory), I get googleapis
pb.go
files copied under proto/googleapis/
folder. I find it very annoying and cannot figure out what is wrong with my setup. If I specify every file directly, everything is fine (e.g. buf generate --path=./proto/api.proto
), no third-party content is copied.
Is there a way to ignore third_party
folders on buf generate
and if not is there a better way to manage grpc dependencies. Copying files into every grpc project directly does make any sense for me.