github.com/gogo/protobuf@v1.3.2/protoc-gen-gogo/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  option go_package = "github.com/gogo/protobuf/protoc-gen-gogo/testdata/my_test;test";
    38  
    39  //import "imp.proto";
    40  import "multi/multi1.proto";  // unused import
    41  
    42  enum HatType {
    43    // deliberately skipping 0
    44    FEDORA = 1;
    45    FEZ = 2;
    46  }
    47  
    48  // This enum represents days of the week.
    49  enum Days {
    50    option allow_alias = true;
    51  
    52    MONDAY = 1;
    53    TUESDAY = 2;
    54    LUNDI = 1;  // same value as MONDAY
    55  }
    56  
    57  // This is a message that might be sent somewhere.
    58  message Request {
    59    enum Color {
    60      RED = 0;
    61      GREEN = 1;
    62      BLUE = 2;
    63    }
    64    repeated int64 key = 1;
    65  //  optional imp.ImportedMessage imported_message = 2;
    66    optional Color hue = 3; // no default
    67    optional HatType hat = 4 [default=FEDORA];
    68  //  optional imp.ImportedMessage.Owner owner = 6;
    69    optional float deadline = 7 [default=inf];
    70    optional group SomeGroup = 8 {
    71      optional int32 group_field = 9;
    72    }
    73  
    74    // These foreign types are in imp2.proto,
    75    // which is publicly imported by imp.proto.
    76  //  optional imp.PubliclyImportedMessage pub = 10;
    77  //  optional imp.PubliclyImportedEnum pub_enum = 13 [default=HAIR];
    78  
    79  
    80    // This is a map field. It will generate map[int32]string.
    81    map<int32, string> name_mapping = 14;
    82    // This is a map field whose value type is a message.
    83    map<sint64, Reply> msg_mapping = 15;
    84  
    85    optional int32 reset = 12;
    86    // This field should not conflict with any getters.
    87    optional string get_key = 16;
    88  
    89    optional float float_ninf = 20 [default=-inf];
    90    optional float float_pinf = 21 [default=inf];
    91    optional float float_exp = 22 [default=1e9];
    92    optional double double_ninf = 23 [default=-inf];
    93    optional double double_pinf = 24 [default=inf];
    94    optional double double_exp = 25 [default=1e9];
    95  }
    96  
    97  message Reply {
    98    message Entry {
    99      required int64 key_that_needs_1234camel_CasIng = 1;
   100      optional int64 value = 2 [default=7];
   101      optional int64 _my_field_name_2 = 3;
   102      enum Game {
   103        FOOTBALL = 1;
   104        TENNIS = 2;
   105      }
   106    }
   107    repeated Entry found = 1;
   108    repeated int32 compact_keys = 2 [packed=true];
   109    extensions 100 to max;
   110  }
   111  
   112  message OtherBase {
   113    optional string name = 1;
   114    extensions 100 to max;
   115  }
   116  
   117  message ReplyExtensions {
   118    extend Reply {
   119      optional double time = 101;
   120      optional ReplyExtensions carrot = 105;
   121    }
   122    extend OtherBase {
   123      optional ReplyExtensions donut = 101;
   124    }
   125  }
   126  
   127  message OtherReplyExtensions {
   128    optional int32 key = 1;
   129  }
   130  
   131  // top-level extension
   132  extend Reply {
   133    optional string tag = 103;
   134    optional OtherReplyExtensions donut = 106;
   135  //  optional imp.ImportedMessage elephant = 107;  // extend with message from another file.
   136  }
   137  
   138  message OldReply {
   139    // Extensions will be encoded in MessageSet wire format.
   140    option message_set_wire_format = true;
   141    extensions 100 to max;
   142  }
   143  
   144  message Communique {
   145    optional bool make_me_cry = 1;
   146  
   147    // This is a oneof, called "union".
   148    oneof union {
   149      int32 number = 5;
   150      string name = 6;
   151      bytes data = 7;
   152      double temp_c = 8;
   153      float height = 9;
   154      Days today = 10;
   155      bool maybe = 11;
   156      sint32 delta = 12;  // name will conflict with Delta below
   157      Reply msg = 16;  // requires two bytes to encode field tag
   158      group SomeGroup = 14 {
   159        optional string member = 15;
   160      }
   161    }
   162  
   163    message Delta {}
   164  }
   165