Stupid simple sample to try gRPC and Go (blatantly ripped from the official helloworld example).
This will be used as a server (although there's a client here for testing), and there's a C# client here.
Consider I'm on Windows for the next steps
- Installed Protobuf compiler (protoc)
- Installed Go :)
- Set GOPATH environment variable to where the projects will be kept
- Installed gRPC for Go
go get google.golang.org/grpc
- Installed the Go code generator plugin
go get -u github.com/golang/protobuf/protoc-gen-go
(it will be on the GOPATH and protoc is able to find it)
- Created the project folder under src, under GOPATH
- Created the service definition (servicedef folder), consisting on the messages to pass (IncrementRequest and IncrementResponse) and the available operations (service Counter.Increment)
- Generated the Go files from the proto definition running the following command on the root of the project
protoc --go_out=plugins=grpc:generated servicedef/*.proto
- Installed the generated package on my GOPATH by running the following command (still on the project root)
go install ./generated/servicedef
- Implemented the server on server\main.go and the client on client\main.go
- On a command window ran the server
go run server\main.go
- On another command window ran the client
go run client\main.go
- Stuff works, YAY!
Followed parts of the gRPC Go Quick Start and the helloworld example.