mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-23 20:02:22 +00:00
Update ch4-06-grpc-ext.md
This commit is contained in:
parent
9c0935eb55
commit
cb51546674
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user