项目作者: n704

项目描述 :
Go gRPC example
高级语言: Go
项目地址: git://github.com/n704/go_grpc_eg.git
创建时间: 2018-04-25T09:31:03Z
项目社区:https://github.com/n704/go_grpc_eg

开源协议:

下载


GO gRPC Example Square

This example is based on command line tool

Installation

Installing all dependency files are managed by dep package manager

  1. go get -u github.com/golang/dep/cmd/dep
  2. dep ensure

Working

Example I have written uses a server client communication using tcp
Client invoke server’s service to get result.
In this example Server does 2 function

  • Square
    • Return square of number
    • default number is 1
  • Cube
    • Return cube of number
    • default number is 1
  1. go run client/main.go -square 122 -cube 9
  2. 2018/04/26 15:10:54 Square of 122: 14884
  3. 2018/04/26 15:10:54 Cube of 9: 729

Runing

For this to work we need to run first run server and client.

Server

  1. go run server/main.go

Client

  1. go run client/main.go