grpc安装
mkdir -p $GOPATH/src/google.golang.org/grpc
cd $GOPATH/src/google.golang.org/grpc
git clone https://github.com/grpc/grpc-go.git
// 以下是为了 把 grpc/grpc-go --> grpc 目录
mv grpc-go ..
cd ..
rm -r grpc
mv grpc-go grpc
安装依赖包, 注意路径必须完全对的上
cd $GOPATH/src/golang.org/x
git clone https://github.com/golang/net.git
git clone https://github.com/golang/text.git
cd $GOPATH/src/google.golang.org
git clone https://github.com/google/go-genproto.git
mv go-genproto/ genproto
安装protobuf
按照github提示
For non-C++ users, the simplest way to install the protocol compiler is to
download a pre-built binary from our release page:
我下了个 all的 protobuf-all-3.6.0.tar.gz
还以为已经编译好了,没想是份源码
那就练练手,源码构建个出来吧
切换到src目录下 打开 README.md
sudo apt-get install autoconf automake libtool curl make g++ unzip
貌似我原来就装好了
$ ./configure
$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.
make check 非常慢 耐心等待
装好后可以看看版本号
~/go/gopath $ protoc --version
libprotoc 3.6.0
安装 protoc-gen-go
go get github.com/golang/protobuf
go install github.com/golang/protobuf/protoc-gen-go/