github.com/whiteCcinn/protobuf-go@v1.0.9/internal/testprotos/textpb2/test.proto (about)

     1  // Copyright 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Test Protobuf definitions with proto2 syntax.
     6  syntax = "proto2";
     7  
     8  package pb2;
     9  option go_package = "github.com/whiteCcinn/protobuf-go/internal/testprotos/textpb2";
    10  
    11  import "google/protobuf/any.proto";
    12  import "google/protobuf/empty.proto";
    13  import "google/protobuf/field_mask.proto";
    14  import "google/protobuf/duration.proto";
    15  import "google/protobuf/struct.proto";
    16  import "google/protobuf/timestamp.proto";
    17  import "google/protobuf/wrappers.proto";
    18  
    19  // Scalars contains optional scalar fields.
    20  message Scalars {
    21    optional bool opt_bool = 1;
    22    optional int32 opt_int32 = 2;
    23    optional int64 opt_int64 = 3;
    24    optional uint32 opt_uint32 = 4;
    25    optional uint64 opt_uint64 = 5;
    26    optional sint32 opt_sint32 = 6;
    27    optional sint64 opt_sint64 = 7;
    28    optional fixed32 opt_fixed32 = 8;
    29    optional fixed64 opt_fixed64 = 9;
    30    optional sfixed32 opt_sfixed32 = 10;
    31    optional sfixed64 opt_sfixed64 = 11;
    32  
    33    // Textproto marshal outputs fields in the same order as this proto
    34    // definition regardless of field number. Following fields are intended to
    35    // test that assumption.
    36  
    37    optional float opt_float = 20;
    38    optional double opt_double = 21;
    39  
    40    optional bytes opt_bytes = 14;
    41    optional string opt_string = 13;
    42  }
    43  
    44  enum Enum {
    45    ONE = 1;
    46    TWO = 2;
    47    TEN = 10;
    48  }
    49  
    50  // Message contains enum fields.
    51  message Enums {
    52    optional Enum opt_enum = 1;
    53    repeated Enum rpt_enum = 2;
    54  
    55    enum NestedEnum {
    56  	UNO = 1;
    57  	DOS = 2;
    58  	DIEZ = 10;
    59    }
    60    optional NestedEnum opt_nested_enum = 3;
    61    repeated NestedEnum rpt_nested_enum = 4;
    62  }
    63  
    64  // Message contains repeated fields.
    65  message Repeats {
    66    repeated bool rpt_bool = 1;
    67    repeated int32 rpt_int32 = 2;
    68    repeated int64 rpt_int64 = 3;
    69    repeated uint32 rpt_uint32 = 4;
    70    repeated uint64 rpt_uint64 = 5;
    71    repeated float rpt_float = 6;
    72    repeated double rpt_double = 7;
    73    repeated string rpt_string = 8;
    74    repeated bytes rpt_bytes = 9;
    75  }
    76  
    77  // Message contains map fields.
    78  message Maps {
    79    map<int32, string> int32_to_str = 1;
    80    map<string, Nested> str_to_nested = 4;
    81  }
    82  
    83  // Message type used as submessage.
    84  message Nested {
    85    optional string opt_string = 1;
    86    optional Nested opt_nested = 2;
    87  }
    88  
    89  // Message contains message and group fields.
    90  message Nests {
    91    optional Nested opt_nested = 1;
    92    optional group OptGroup = 2 {
    93      optional string opt_string = 1;
    94      optional Nested opt_nested = 2;
    95  
    96      optional group OptNestedGroup = 3 {
    97        optional fixed32 opt_fixed32 = 1;
    98      }
    99    }
   100  
   101    repeated Nested rpt_nested = 4;
   102    repeated group RptGroup = 5 {
   103      repeated string rpt_string = 1;
   104    }
   105  
   106    reserved "reserved_field";
   107  }
   108  
   109  // Message contains required fields.
   110  message Requireds {
   111    required bool req_bool = 1;
   112    required sfixed64 req_sfixed64 = 2;
   113    required double req_double = 3;
   114    required string req_string = 4;
   115    required Enum req_enum = 5;
   116    required Nested req_nested = 6;
   117  }
   118  
   119  // Message contains both required and optional fields.
   120  message PartialRequired {
   121    required string req_string = 1;
   122    optional string opt_string = 2;
   123  }
   124  
   125  // Following messages are for testing required field nested in optional, repeated and map fields.
   126  
   127  message NestedWithRequired {
   128    required string req_string = 1;
   129  }
   130  
   131  message IndirectRequired {
   132    optional NestedWithRequired opt_nested = 1;
   133    repeated NestedWithRequired rpt_nested = 2;
   134    map<string, NestedWithRequired> str_to_nested = 3;
   135  
   136    oneof union {
   137      NestedWithRequired oneof_nested = 4;
   138    }
   139  }
   140  
   141  // Following messages are for testing extensions.
   142  
   143  message Extensions {
   144    optional string opt_string = 1;
   145    extensions 20 to 100;
   146    optional bool opt_bool = 101;
   147    optional int32 opt_int32 = 2;
   148  }
   149  
   150  extend Extensions {
   151    optional bool opt_ext_bool = 21;
   152    optional string opt_ext_string = 22;
   153    optional Enum opt_ext_enum = 23;
   154    optional Nested opt_ext_nested = 24;
   155    optional PartialRequired opt_ext_partial = 25;
   156  
   157    repeated fixed32 rpt_ext_fixed32 = 31;
   158    repeated Enum rpt_ext_enum = 32;
   159    repeated Nested rpt_ext_nested = 33;
   160  }
   161  
   162  message ExtensionsContainer {
   163    extend Extensions {
   164      optional bool opt_ext_bool = 51;
   165      optional string opt_ext_string = 52;
   166      optional Enum opt_ext_enum = 53;
   167      optional Nested opt_ext_nested = 54;
   168      optional PartialRequired opt_ext_partial = 55;
   169  
   170      repeated string rpt_ext_string = 61;
   171      repeated Enum rpt_ext_enum = 62;
   172      repeated Nested rpt_ext_nested = 63;
   173    }
   174  }
   175  
   176  // Following messages are for testing MessageSet.
   177  
   178  message MessageSet {
   179    option message_set_wire_format = true;
   180  
   181    extensions 4 to max;
   182  }
   183  
   184  message MessageSetExtension {
   185    optional string opt_string = 1;
   186  
   187    extend MessageSet {
   188      optional MessageSetExtension message_set_extension = 10;
   189      optional MessageSetExtension not_message_set_extension = 20;
   190      optional Nested ext_nested = 30;
   191    }
   192  }
   193  
   194  message FakeMessageSet {
   195    extensions 4 to max;
   196  }
   197  
   198  message FakeMessageSetExtension {
   199    optional string opt_string = 1;
   200  
   201    extend FakeMessageSet {
   202      optional FakeMessageSetExtension message_set_extension = 10;
   203    }
   204  }
   205  
   206  extend MessageSet {
   207    optional FakeMessageSetExtension message_set_extension = 50;
   208  }
   209  
   210  // Message contains well-known type fields.
   211  message KnownTypes {
   212    optional google.protobuf.BoolValue opt_bool = 1;
   213    optional google.protobuf.Int32Value opt_int32 = 2;
   214    optional google.protobuf.Int64Value opt_int64 = 3;
   215    optional google.protobuf.UInt32Value opt_uint32 = 4;
   216    optional google.protobuf.UInt64Value opt_uint64 = 5;
   217    optional google.protobuf.FloatValue opt_float = 6;
   218    optional google.protobuf.DoubleValue opt_double = 7;
   219    optional google.protobuf.StringValue opt_string = 8;
   220    optional google.protobuf.BytesValue opt_bytes = 9;
   221  
   222    optional google.protobuf.Duration opt_duration = 20;
   223    optional google.protobuf.Timestamp opt_timestamp = 21;
   224  
   225    optional google.protobuf.Struct opt_struct = 25;
   226    optional google.protobuf.ListValue opt_list = 26;
   227    optional google.protobuf.Value opt_value = 27;
   228    optional google.protobuf.NullValue opt_null = 28;
   229  
   230    optional google.protobuf.Empty opt_empty = 30;
   231    optional google.protobuf.Any opt_any = 32;
   232  
   233    optional google.protobuf.FieldMask opt_fieldmask = 40;
   234  }