From cb51546674af34867e85c12d9371247e06461b2e Mon Sep 17 00:00:00 2001 From: smallwhite Date: Fri, 8 Mar 2019 10:09:56 +0800 Subject: [PATCH 1/2] Update ch4-06-grpc-ext.md --- ch4-rpc/ch4-06-grpc-ext.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ch4-rpc/ch4-06-grpc-ext.md b/ch4-rpc/ch4-06-grpc-ext.md index c9d1507..1f46307 100644 --- a/ch4-rpc/ch4-06-grpc-ext.md +++ b/ch4-rpc/ch4-06-grpc-ext.md @@ -125,10 +125,15 @@ protoc \ --proto_path=${GOPATH}/src \ --proto_path=${GOPATH}/src/github.com/google/protobuf/src \ --proto_path=. \ - --govalidators_out=. \ + --govalidators_out=. --go_out=plugins=grpc:.\ hello.proto ``` +> windows: +``` +protoc --proto_path=%GOPATH%/src --proto_path=%GOPATH%/src/github.com/google/protobuf/src --proto_path=. --govalidators_out=. --go_out=plugins=grpc:. hello.proto +``` + 以上的命令会调用protoc-gen-govalidators程序,生成一个独立的名为hello.validator.pb.go的文件: ```go @@ -213,10 +218,15 @@ go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway $ protoc -I/usr/local/include -I. \ -I$GOPATH/src \ -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ - --grpc-gateway_out=. \ + --grpc-gateway_out=. --go_out=plugins=grpc:.\ hello.proto ``` +> windows: +``` +protoc -I. -I%GOPATH%/src -I%GOPATH%/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=. --go_out=plugins=grpc:. hello.proto +``` + 插件会为RestService服务生成对应的RegisterRestServiceHandlerFromEndpoint函数: ```go From 8b2ca8b7b261efdff1092c45f420b6a0f10d8a56 Mon Sep 17 00:00:00 2001 From: smallwhite Date: Fri, 8 Mar 2019 10:14:47 +0800 Subject: [PATCH 2/2] Update ch4-06-grpc-ext.md --- ch4-rpc/ch4-06-grpc-ext.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ch4-rpc/ch4-06-grpc-ext.md b/ch4-rpc/ch4-06-grpc-ext.md index 1f46307..2942fac 100644 --- a/ch4-rpc/ch4-06-grpc-ext.md +++ b/ch4-rpc/ch4-06-grpc-ext.md @@ -129,10 +129,8 @@ protoc \ hello.proto ``` -> windows: -``` -protoc --proto_path=%GOPATH%/src --proto_path=%GOPATH%/src/github.com/google/protobuf/src --proto_path=. --govalidators_out=. --go_out=plugins=grpc:. hello.proto -``` +> windows:替换 `${GOPATH}` 为 `%GOPATH%` 即可. + 以上的命令会调用protoc-gen-govalidators程序,生成一个独立的名为hello.validator.pb.go的文件: @@ -222,10 +220,7 @@ $ protoc -I/usr/local/include -I. \ hello.proto ``` -> windows: -``` -protoc -I. -I%GOPATH%/src -I%GOPATH%/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=. --go_out=plugins=grpc:. hello.proto -``` +> windows:替换 `${GOPATH}` 为 `%GOPATH%` 即可. 插件会为RestService服务生成对应的RegisterRestServiceHandlerFromEndpoint函数: