Compile with the gRPC Plugin
Distributed Services with Go — by Travis Jeffery (33 / 84)
👈 Define a gRPC Service | TOC | Implement a gRPC Server 👉
This task takes just a second. Install the gRPC package by running this command:
$ go get google.golang.org/grpc@v1.32.0
$ go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.0.0
Then open up your Makefile and update your compile target to match the following to enable the gRPC plugin and compile our gRPC service:
ServeRequestsWithgRPC/Makefile
compile:
protoc api/v1/*.proto \
--go_out=. \
--go-grpc_out=. \
--go_opt=paths=source_relative \
--go-grpc_opt=paths=source_relative \
--proto_path=.
Run $ make compile, and then open up the log_grpc.pb.go file in the api/v1 directory and check out the generated code. You’ll see a working gRPC log client, and the compiler left the log service API for us to implement.
👈 Define a gRPC Service | TOC | Implement a gRPC Server 👉
Distributed Services with Go by Travis Jeffery can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.