Install
- Download latest release of
protobuf
. (Note:proto/include
in this repo is copied fromprotobuf
.) - Install
grpc
:go get -u google.golang.org/grpc
. - Install
protoc-gen-go
:go get -u github.com/golang/protobuf/protoc-gen-go
. - Regenerate
service.pb.go
:protoc --proto_path=proto --go_out=plugins=grpc:proto service.proto
. - Install
gin
:go get -u github.com/gin-gonic/gin
.
Run
- Run server:
go run server/main.go
. - Run client:
go run client/main.go
. - Test api endpoints:
curl http://localhost:4002/calculate/4/+/2
.curl http://localhost:4002/calculate/4/-/2
.curl http://localhost:4002/calculate/4/*/2
.curl http://localhost:4002/calculate/4/divide/2
.
- Test errors:
curl http://localhost:4002/calculate/4/divide/0
(cannot divide by zero).curl http://localhost:4002/calculate/4/asdf/2
(bad operator).