-
Notifications
You must be signed in to change notification settings - Fork 0
CRORCR/cr-common
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
protoc --go_out=plugins=grpc,paths=source_relative:. proto/student/*.proto protoc --go_out=plugins=grpc,paths=source_relative:. proto/base/*.proto protoc --go_out=plugins=grpc,paths=source_relative:. infrastructure/proto/his_api/engine_order/*.proto protoc --go_out=plugins=grpc,paths=source_relative:. infrastructure/proto/his_api/his_transfer/*.proto protoc --go_out=plugins=grpc,paths=source_relative:. infrastructure/proto/his_api/his_wallet/*.proto protoc --go_out=plugins=grp .c,paths=source_relative:. proto/engine_order/*.proto //protoc -I . --go_out=plugins=grpc:. ./student.proto --proto_path 或者 -I 参数用以指定所编译源码的搜索路径 --go_out 参数是用来指定 protoc-gen-go 插件的工作方式 和 go 代码目录架构的生成位置 主要的两个参数为 plugins 和 paths,参数之间用逗号隔开,代表 生成 go 代码所使用的插件 和 生成的 go 代码的目录怎样架构。 最后加上冒号来指定代码目录架构的生成位置,例如:--go_out=plugins=grpc,paths=import:. source_relative 代表按照 proto 源文件的目录层级去创建 go 代码的目录层级 ,如果目录已存在则不用创建。 --go_out=paths=source_relative:. 为了让加了 option go_package 声明的 proto 文件可以将 go 代码编译到与其同目录。 如果需要引入其他包,就在文件头部引入(不要根路径) import "proto/base/base.proto"; message里面就可以用了,包名.结构名 base.Pagination pag = 4; proto表示数组:使用repeated关键字 repeated Logs logs = 3; proto生成的结构体,json传输默认忽略空值。有时候,我们需要默认值,那就自己手动把所有的(omitempty),替换成空
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published