Method 1

  • Set up a VPN and then refer to grpc.io

Method 2

  1. Install Go (gRPC requires Go 1.6 or higher)

    # https://www.cnblogs.com/pyyu/p/8032257.html
    cd /home/heyongchao 
    mkdir go && cd go && mkdir bin && mkdir src && mkdir pkg
    wget https://golang.google.cn/dl/go<version>-<arch>.tar.gz
    tar xvf go<version>-<arch>.tar.gz -C /usr/local
       
    # vi /etc/profile <https://www.cnblogs.com/pyyu/p/8032257.html>
    export GOROOT=/usr/local/go
    export PATH=$PATH:$GOROOT/bin
    export GOPATH=/home/heyongchao/go
    export PATH=$PATH:$GOPATH/bin
    source /etc/profile
    
  2. Install Protocol Buffers v3

    # https://grpc.io/docs/quickstart/go
    cd /usr/local
    mkdir protobuf && cd protobuf
    wget https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/protoc-3.8.0-linux-x86_64.zip
    unzip protoc-3.8.0-linux-x86_64.zip
       
    # vi /etc/profile
    export PATH=$PATH:/usr/local/protobuf/bin
    source /etc/profile
    
  3. Install the protoc plugin for Go

    # default $GOPATH/bin
    go get -u github.com/golang/protobuf/protoc-gen-go
    
  4. Install gRPC

    git clone https://github.com/golang/net.git           $GOPATH/src/golang.org/x/net
    git clone https://github.com/golang/text.git          $GOPATH/src/golang.org/x/text
    git clone https://github.com/golang/sys.git           $GOPATH/src/golang.org/x/sys
    git clone https://github.com/google/go-genproto.git   $GOPATH/src/google.golang.org/genproto
    git clone https://github.com/grpc/grpc-go.git         $GOPATH/src/google.golang.org/grpc
    git clone https://github.com/go-sql-driver/mysql.git  $GOPATH/src/github.com/go-sql-driver/mysql
    
  5. Hello world

    cp -r $GOPATH/src/google.golang.org/grpc/examples/helloworld $GOPATH/src/
    cd helloworld
       
    protoc --go_out=plugins=grpc:. helloworld/helloworld.proto
    go run greeter_server/main.go
    go run greeter_client/main.go