一、安裝
官方安裝命令: go get -u google.golang.org/grpc
由於google無法訪問,雖然github上有grpc的代碼,但是包依賴沒有修改,所以不能go get安裝,需要手動安裝。
git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/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
go get -u github.com/golang/protobuf/protoc-gen-go
git clone https://github.com/google/go-genproto.git $GOPATH/src/google.golang.org/genproto
cd $GOPATH/src/
go install google.golang.org/grpc
$GOPATH替換為環境變量的實際路徑。
二、編譯.proto文件
protoc --go_out=plugins=grpc:. x.proto
