syntax = "proto3"; // 版本号 option go_package="./;proto"; //参数1 表示生成到哪个目录 ,参数2 表示生成的文件的package package proto ; //默认在哪个包 //结构体 message Order { int64 id = 1; string no = 2; string tel =3; string address = 4; string addTime = 5; OrderStatus status = 6; message Producets { int64 id = 1; string title = 2; double price =3; int32 num = 4; } Producets producets = 7; } //也可写这里 // message Producets { // int64 id = 1; // string title = 2; // double price =3; // int32 num = 4; // } //请求 request struct message OrderRequest { int32 activityType = 1; } //响应 resp struct message OrderResp{ int32 discountAmount = 1; string code = 2; string msg = 3; } enum OrderStatus { FIRST_VAL = 0 ; //The first enum value must be zero in proto3. SECOND_VAL = 1; } //RPC 服务 接口 service SearchService { //rpc 服务 rpc SearchOrder (OrderRequest) returns (OrderResp){} }