[gRPC] Generate .pb.go from .proto
Generate .pb.go automatically using .proto file in Windows
For example, let's assume that we have following .proto written
In order for us to use this nodes.proto
, we need to have nodes.pb.go
file. We can achieve that by following instruction under Windows 10 environment:
I am assuming that you have your GOPATH and all PATH environment variables set correctly.
1. Install Protocol Buffers
Extract
.zip
and setPATH.
2. Install Plugins
We need some things like protoc-gen-*
to generate grpc stuff
3. Generate .pb.go
When you have set your go_package
as following:
This will generate your nodes.pb.go
file under ./nodes
directory. To do this, execute following command in the same directory where your nodes.proto
resides in:
This will generate the .pb.go
file for gRPC
4. Generate _grpc.pb.go
Just like .pb.go
, following command will generate nodes_grpc.pb.go
under ./nodes
directory. To do this, execute following command in the same directory where your nodes.proto
resides in:
Last updated