github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/golang/protobuf/protoc-gen-go/testdata/my_test/test.proto (about)

     1  // Go support for Protocol Buffers - Google's data interchange format
     2  //
     3  // Copyright 2010 The Go Authors.  All rights reserved.
     4  // https://github.com/golang/protobuf
     5  //
     6  // Redistribution and use in source and binary forms, with or without
     7  // modification, are permitted provided that the following conditions are
     8  // met:
     9  //
    10  //     * Redistributions of source code must retain the above copyright
    11  // notice, this list of conditions and the following disclaimer.
    12  //     * Redistributions in binary form must reproduce the above
    13  // copyright notice, this list of conditions and the following disclaimer
    14  // in the documentation and/or other materials provided with the
    15  // distribution.
    16  //     * Neither the name of Google Inc. nor the names of its
    17  // contributors may be used to endorse or promote products derived from
    18  // this software without specific prior written permission.
    19  //
    20  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    21  // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    22  // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    23  // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    24  // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    25  // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    26  // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    27  // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    28  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    29  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    30  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31  
    32  syntax = "proto2";
    33  
    34  // This package holds interesting messages.
    35  package my.test;  // dotted package name
    36  
    37  //import "imp.proto";
    38  import "multi/multi1.proto";  // unused import
    39  
    40  enum HatType {
    41    // deliberately skipping 0
    42    FEDORA = 1;
    43    FEZ = 2;
    44  }
    45  
    46  // This enum represents days of the week.
    47  enum Days {
    48    option allow_alias = true;
    49  
    50    MONDAY = 1;
    51    TUESDAY = 2;
    52    LUNDI = 1;  // same value as MONDAY
    53  }
    54  
    55  // This is a message that might be sent somewhere.
    56  message Request {
    57    enum Color {
    58      RED = 0;
    59      GREEN = 1;
    60      BLUE = 2;
    61    }
    62    repeated int64 key = 1;
    63  //  optional imp.ImportedMessage imported_message = 2;
    64    optional Color hue = 3; // no default
    65    optional HatType hat = 4 [default=FEDORA];
    66  //  optional imp.ImportedMessage.Owner owner = 6;
    67    optional float deadline = 7 [default=inf];
    68    optional group SomeGroup = 8 {
    69      optional int32 group_field = 9;
    70    }
    71  
    72    // These foreign types are in imp2.proto,
    73    // which is publicly imported by imp.proto.
    74  //  optional imp.PubliclyImportedMessage pub = 10;
    75  //  optional imp.PubliclyImportedEnum pub_enum = 13 [default=HAIR];
    76  
    77  
    78    // This is a map field. It will generate map[int32]string.
    79    map<int32, string> name_mapping = 14;
    80    // This is a map field whose value type is a message.
    81    map<sint64, Reply> msg_mapping = 15;
    82  
    83    optional int32 reset = 12;
    84    // This field should not conflict with any getters.
    85    optional string get_key = 16;
    86  }
    87  
    88  message Reply {
    89    message Entry {
    90      required int64 key_that_needs_1234camel_CasIng = 1;
    91      optional int64 value = 2 [default=7];
    92      optional int64 _my_field_name_2 = 3;
    93      enum Game {
    94        FOOTBALL = 1;
    95        TENNIS = 2;
    96      }
    97    }
    98    repeated Entry found = 1;
    99    repeated int32 compact_keys = 2 [packed=true];
   100    extensions 100 to max;
   101  }
   102  
   103  message OtherBase {
   104    optional string name = 1;
   105    extensions 100 to max;
   106  }
   107  
   108  message ReplyExtensions {
   109    extend Reply {
   110      optional double time = 101;
   111      optional ReplyExtensions carrot = 105;
   112    }
   113    extend OtherBase {
   114      optional ReplyExtensions donut = 101;
   115    }
   116  }
   117  
   118  message OtherReplyExtensions {
   119    optional int32 key = 1;
   120  }
   121  
   122  // top-level extension
   123  extend Reply {
   124    optional string tag = 103;
   125    optional OtherReplyExtensions donut = 106;
   126  //  optional imp.ImportedMessage elephant = 107;  // extend with message from another file.
   127  }
   128  
   129  message OldReply {
   130    // Extensions will be encoded in MessageSet wire format.
   131    option message_set_wire_format = true;
   132    extensions 100 to max;
   133  }
   134  
   135  message Communique {
   136    optional bool make_me_cry = 1;
   137  
   138    // This is a oneof, called "union".
   139    oneof union {
   140      int32 number = 5;
   141      string name = 6;
   142      bytes data = 7;
   143      double temp_c = 8;
   144      float height = 9;
   145      Days today = 10;
   146      bool maybe = 11;
   147      sint32 delta = 12;  // name will conflict with Delta below
   148      Reply msg = 13;
   149      group SomeGroup = 14 {
   150        optional string member = 15;
   151      }
   152    }
   153  
   154    message Delta {}
   155  }
   156