天天看點

Protobuf文法:Required,Optional,extensions,extend

import "test_common.proto";

message Person 
{  
  required Header header = 1;
  required string id = 2;
  required string name = 3;    
  optional int32 age = 4 [default = 18];
  optional string email = 5 [default = "[email protected]"];
  repeated int32 array = 6;  

  extensions 10 to max;
}

message Phone 
{
    extend Person { repeated Phone phones = 10;}

    enum PHONE_TYPE
    {
        MOBILE = 1;
        HOME = 2;
    }
    optional string num = 1;
    optional PHONE_TYPE type = 2;
}