You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

166 lines
4.8 KiB

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