Skip to content

Instantly share code, notes, and snippets.

@jesselucas
Last active January 29, 2019 01:23
Show Gist options
  • Save jesselucas/c8463ceed6ca73e8c5a693e1c54c0dc0 to your computer and use it in GitHub Desktop.
Save jesselucas/c8463ceed6ca73e8c5a693e1c54c0dc0 to your computer and use it in GitHub Desktop.
Tips for generating gRPC protocol buffers

Tips for generating gRPC protocol buffers

You can use the flag -I or -proto_path to specify the path to your protobuffer. The next flag specifies the language to compile to. The Go command is fairly well documented but the Node.js documents seem to only show how to dynamically load a proto file. This is how you generate a compiled file for use in your Node.js project.

GO

protoc --proto_path=$SRC_PATH --go_out=plugins=grpc:$DEST_PATH $SRC_PATH/service.proto

Node.js

protoc --proto_path=$SRC_PATH --js_out=import_style=commonjs,binary:$DEST_PATH --grpc_out=./ --plugin=protoc-gen-grpc=node_modules/grpc-tools/bin/grpc_node_plugin $SRC_PATH/service.proto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment