您好,登錄后才能下訂單哦!
1> Ubuntu16.04 集成的go包是1.6,后期有坑,直接安裝1.9.
To install Go 1.9 on Ubuntu 16.04, first add the PPA and install the golang-1.9-go package:
sudo add-apt-repository ppa:gophers/archive
sudo apt update
sudo apt-get install golang-1.9-go
The add go the go path to the your PATH:
echo "export PATH=$PATH:/usr/lib/go-1.9/bin" >> ~/.profile
Then finally load the new path:
source ~/.profile
Although everything should now work, it might be wise to just log out and back in to make sure other programs also get the updated path.
2>配置好GOPATH;
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH/bin
之后protoc-gen-go會放到 $GOBIN 下
3>安裝protoc 3.6.1
直接復制模式
Install Protocol Buffers v3
Install the protoc compiler that is used to generate gRPC service code. The simplest way to do this is to download pre-compiled binaries for your platform(protoc-<version>-<platform>.zip) from here: https://github.com/google/protobuf/releases
Unzip this file.
Update the environment variable PATH to include the path to the protoc binary file.
4> Install gRPC
go get -u google.golang.org/grpc
5> Install the protoc plugin for Go
go get -u github.com/golang/protobuf/protoc-gen-go
6>Download the example
You can found under the examples dir: $GOPATH/src/google.golang.org/grpc/examples
7>Build the example
helloworld.proto => helloworld.pb.go
protoc -I helloworld/ helloworld/helloworld.proto --go_out=plugins=grpc:helloworld
8>在倆個窗口執行
go run greeter_server/main.go
go run greeter_client/main.go
以上就是go服務端/ go客戶端
=========================================================
1>安裝grpc_php_plugin等插件
1》sudo apt-get install php7.0 php7.0-dev php-pear phpunit
2》Install Composer (Linux or Mac):
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
3安裝擴展
sudo pecl install grpc
sudo pecl install grpc-1.7.0
sudo pecl install protobuf
sudo pecl install protobuf-3.4.0
update php.ini
4》安裝插件
$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
$ cd grpc
$ git submodule update --init
$ make //編譯全部插件
$ make grpc_php_plugin //只編譯php插件
如果有這個報錯 defined but not used [-Werror=unused-variable]
找到Makefile,去掉其中-Werror ,重新編譯。
5》 find php example
cd examples/php (grpc/examples/php)
6》helloworld.proto => hello.world.pb.go
./greeter_proto_gen.sh
7》執行client之前,需要引包
composer install
8》服務端是go,現在客戶端在php
./run_greeter_client.sh
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。