If you not familiar with gRPC you may want to read Introduction to gRPC first.
- Go, we were using version 1.15.x when this document was created. For installation instructions, see Go’s Getting Started Guide
- Protocol buffer compiler,
protoc
, version 3. For installation instructions, see Protocol Buffer Compiler Installation - Go plugin for the protocol compiler:
Install the protocol compiler plugin for Go (protoc-gen-go) using the following command:
export GO111MODULE=on # Enable module mode
go get github.com/golang/protobuf/protoc-gen-go
Update your PATH so that the protoc compiler can find the plugin:
export PATH="$PATH:$(go env GOPATH)/bin"
protoc --go_out=plugins=grpc:../. protobuf/helloworld.proto
generate grpc-gateway
protoc --grpc-gateway_out ../. protobuf/helloworld.proto
generate swagger config
protoc --swagger_out . protobuf/helloworld.proto
or generate everything at once
protoc --go_out=plugins=grpc:../. --grpc-gateway_out ../. --swagger_out . protobuf/helloworld.proto
go run server/main.go
go run rest/main.go
go run client/main.go [name]