project-layout
project-layout copied to clipboard
gRPC ant proto declarations?
What is a common approach when project is using a protobuf and gRPC?
- Where to keep
*.protofiles? - Where should be generated files placed, near to protobuf declarations or in another place?
- Any other tips to build clean folder layout when using protobuf and grpc?
Thanks to everyone!
*.proto files accordingly to these recommendations should be stored in /api/proto/v1/*.proto. As well generated swagger files in /api/swagger/v1/*.swagger.json.
And what's about generated *.pb.go files?
I am not an expert, so... but i am generating them into /pkg/api/v1.
I have protoc-gen.sh file with content like this:
protoc --proto_path=api/proto/v1 --proto_path=third_party --go_out=plugins=grpc:pkg/api/v1 auth_service.proto
protoc --proto_path=api/proto/v1 --proto_path=third_party --grpc-gateway_out=logtostderr=true:pkg/api/v1 auth_service.proto
protoc --proto_path=api/proto/v1 --proto_path=third_party --swagger_out=logtostderr=true:api/swagger/v1 auth_service.proto
It should be executable - chmod +x protoc-gen.sh
Simply run it by ./scripts/protoc-gen.sh from projects root directory.
third_party in my case contains protobuf annotations, etc.
whoever was "ghost", you helped a lot buddy.