项目作者: akmamun

项目描述 :
Basic gRPC with Go Lang
高级语言: Go
项目地址: git://github.com/akmamun/go-grpc.git
创建时间: 2019-02-18T13:11:53Z
项目社区:https://github.com/akmamun/go-grpc

开源协议:

下载


Install gRPC

  1. go get -u google.golang.org/grpc

Install the protoc plugin for Go

  1. go get -u github.com/golang/protobuf/protoc-gen-go
  2. go install github.com/golang/protobuf/protoc-gen-go

Install protobuf 3 on Ubuntu

  1. curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.0rc2/protoc-3.7.0-rc-2-linux-x86_64.zip
  2. # Unzip
  3. unzip protoc-3.7.0-rc-2-linux-x86_64.zip -d protoc3
  4. # Move protoc to /usr/local/bin/
  5. sudo mv protoc3/bin/* /usr/local/bin/
  6. # Move protoc3/include to /usr/local/include/
  7. sudo mv protoc3/include/* /usr/local/include/

Run Proto Buffer Generator

  • Dot means same directory of proto file
    1. protoc folder_name/file_name.proto --go_out=plugins=grpc:.
    2. example: protoc proto/helloworld.proto --go_out=plugins=grpc:.

    if want to change write name of directory

    1. protoc folder_name/file_name.proto --go_out=plugins=grpc:/directory_name
    2. example: protoc proto/helloworld.proto --go_out=plugins=grpc:/proto

Run both server/main.go and client/main.go

  1. go run main.go