test.proto 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 2018 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. // Test Protobuf definitions with proto3 syntax.
  5. syntax = "proto3";
  6. package pb3;
  7. option go_package = "google.golang.org/protobuf/encoding/testprotos/pb3";
  8. // Scalars contains scalar field types.
  9. message Scalars {
  10. bool s_bool = 1;
  11. int32 s_int32 = 2;
  12. int64 s_int64 = 3;
  13. uint32 s_uint32 = 4;
  14. uint64 s_uint64 = 5;
  15. sint32 s_sint32 = 6;
  16. sint64 s_sint64 = 7;
  17. fixed32 s_fixed32 = 8;
  18. fixed64 s_fixed64 = 9;
  19. sfixed32 s_sfixed32 = 10;
  20. sfixed64 s_sfixed64 = 11;
  21. // Textproto marshal outputs fields in the same order as this proto
  22. // definition regardless of field number. Following fields are intended to
  23. // test that assumption.
  24. float s_float = 20;
  25. double s_double = 21;
  26. bytes s_bytes = 14;
  27. string s_string = 13;
  28. }
  29. enum Enum {
  30. ZERO = 0;
  31. ONE = 1;
  32. TWO = 2;
  33. TEN = 10;
  34. }
  35. // Message contains enum fields.
  36. message Enums {
  37. Enum s_enum = 1;
  38. enum NestedEnum {
  39. CERO = 0;
  40. UNO = 1;
  41. DOS = 2;
  42. DIEZ = 10;
  43. }
  44. NestedEnum s_nested_enum = 3;
  45. }
  46. // Message contains nested message field.
  47. message Nests {
  48. Nested s_nested = 2;
  49. }
  50. // Message type used as submessage.
  51. message Nested {
  52. string s_string = 1;
  53. Nested s_nested = 2;
  54. }
  55. // Message contains oneof field.
  56. message Oneofs {
  57. oneof union {
  58. Enum oneof_enum = 1;
  59. string oneof_string = 2;
  60. Nested oneof_nested = 3;
  61. }
  62. }
  63. // Message contains map fields.
  64. message Maps {
  65. map<int32, string> int32_to_str = 1;
  66. map<bool, uint32> bool_to_uint32 = 2;
  67. map<uint64, Enum> uint64_to_enum = 3;
  68. map<string, Nested> str_to_nested = 4;
  69. map<string, Oneofs> str_to_oneofs = 5;
  70. }
  71. // Message for testing json_name option.
  72. message JSONNames {
  73. string s_string = 1 [json_name = "foo_bar"];
  74. }