gogo protobuf


gogoprotobuf使用(上)
來自 <https://my.oschina.net/alexstocks/blog/387031> 


gogoprotobuf使用(下)
來自 <https://studygolang.com/articles/2575> 




./protoc --gogofast_out=plugins=grpc:../src/github.com/Gauss100_OLTP_DB/consistency/raft/raftpb/ -I../src/github.com/Gauss100_OLTP_DB/consistency/raft/raftpb/ -I ../ -I ../src/github.com/gogo/protobuf/protobuf/  ../src/github.com/Gauss100_OLTP_DB/consistency/raft/raftpb/raft.proto




protoc --gofast_out=. -I/root/Gauss100_OLTP_V1R5_PINETREE/src/github.com/gogo/protobuf/protobuf/ -I/root/Gauss100_OLTP_V1R5_PINETREE/src/  -I. raft.proto
Compiler Invocation
The protocol buffer compiler requires a plugin to generate Go code. Installing it with
$ go get github.com/golang/protobuf/protoc-gen-go
provides a protoc-gen-go binary which protoc uses when invoked with the --go_out command-line flag. The --go_out flag tells the compiler where to write the Go source files. The compiler creates a single source file for each .proto file input.
The names of the output files are computed by taking the name of the .proto file and making two changes:
• The extension (.proto) is replaced with .pb.go. For example, a file called player_record.proto results in an output file called player_record.pb.go.
• The proto path (specified with the --proto_path or -I command-line flag) is replaced with the output path (specified with the --go_out flag).
When you run the proto compiler like this:
protoc --proto_path=src --go_out=build/gen src/foo.proto src/bar/baz.proto
the compiler will read the files src/foo.proto and src/bar/baz.proto. It produces two output files:build/gen/foo.pb.go and build/gen/bar/baz.pb.go.
The compiler automatically creates the directory build/gen/bar if necessary, but it will not create build orbuild/gen; they must already exist.


來自 <https://developers.google.com/protocol-buffers/docs/reference/go-generated#repeated> 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章