安装: # git clone https://github.com/grpc/grpc-go.git $GOPATH/pkg/mod/google.golang.org/grpc # git clone https://github.com/golang/net.git $GOPATH/pkg/mod/golang.org/x/net git clone https://github.com/golang/text.git /$GOPATH/pkg/mod/golang.org/x/text go get -u github.com/golang/protobuf/{proto,protoc-gen-go} git clone https://github.com/google/go-genproto.git $GOPATH/pkg/mod/google.golang.org/genproto protoc \ -I . \ -I ${GOPATH}/src \ -I ${GOPATH}/src/github.com/envoyproxy/protoc-gen-validate \ --go_out=plugins=grpc:../../pb/pb_test/ \ --validate_out="lang=go:../../pb/pb_test/" \ test.proto
命令用法:
protoc -h
Usage: protoc [OPTION] PROTO_FILES
Parse PROTO_FILES and generate output based on the options given:
-IPATH, --proto_path=PATH Specify the directory in which to search for
imports. May be specified multiple times;
directories will be searched in order. If not
given, the current working directory is used.
If not found in any of the these directories,
the --descriptor_set_in descriptors will be
checked for required proto file.
--version Show v