blob: 21edacab1ffba6baa9e667306bc91c9918019a35 [file] [log] [blame]
Herbie Ongcddf8192018-11-28 18:25:20 -08001// 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
5// Test Protobuf definitions with proto2 syntax.
6syntax = "proto2";
7
8package pb2;
9option go_package = "github.com/golang/protobuf/v2/encoding/textpb/testprotos/pb2";
10
11import "google/protobuf/any.proto";
12import "google/protobuf/empty.proto";
13import "google/protobuf/duration.proto";
14import "google/protobuf/struct.proto";
15import "google/protobuf/timestamp.proto";
16import "google/protobuf/wrappers.proto";
17
18// Scalars contains optional scalar fields.
19message Scalars {
20 optional bool opt_bool = 1;
21
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 optional float opt_float = 20;
34 optional double opt_double = 21;
35
36 optional bytes opt_bytes = 14;
37 optional string opt_string = 13;
38}
39
40// Message contains repeated fields.
41message Repeats {
42 repeated bool rpt_bool = 1;
43 repeated int32 rpt_int32 = 2;
44 repeated int64 rpt_int64 = 3;
45 repeated uint32 rpt_uint32 = 4;
46 repeated uint64 rpt_uint64 = 5;
47 repeated float rpt_float = 6;
48 repeated double rpt_double = 7;
49 repeated string rpt_string = 15;
50 repeated bytes rpt_bytes = 14;
51}
52
53enum Enum {
54 UNKNOWN = 0;
55 FIRST = 1;
56 SECOND = 2;
57 TENTH = 10;
58}
59
60// Message contains enum fields.
61message Enums {
62 optional Enum opt_enum = 1;
63 repeated Enum rpt_enum = 2;
64
65 enum NestedEnum {
66 UNO = 1;
67 DOS = 2;
68 DIEZ = 10;
69 }
70 optional NestedEnum opt_nested_enum = 3;
71 repeated NestedEnum rpt_nested_enum = 4;
72}
73
74// Message contains message and group fields.
75message Nests {
76 optional Nested opt_nested = 1;
77 optional group OptGroup = 2 {
78 optional bool opt_bool = 1;
79 optional string opt_string = 2;
80 optional Nested opt_nested = 3;
81
82 optional group OptNestedGroup = 4 {
83 optional Enum opt_enum = 1;
84 }
85 }
86
87 repeated Nested rpt_nested = 3;
88 repeated group RptGroup = 4 {
89 repeated bool rpt_bool = 1;
90 }
91}
92
93// Message type used as submessage.
94message Nested {
95 optional string opt_string = 1;
96 optional Nested opt_nested = 2;
97}
98
99// Message contains required fields.
100message Requireds {
101 required bool req_bool = 1;
102 required fixed32 req_fixed32 = 2;
103 required fixed64 req_fixed64 = 3;
104 required sfixed32 req_sfixed32 = 4;
105 required sfixed64 req_sfixed64 = 5;
106 required float req_float = 6;
107 required double req_double = 7;
108 required string req_string = 8;
109 required bytes req_bytes = 9;
110 required Enum req_enum = 10;
111 required Nested req_nested = 11;
112}
113
114// Message contains oneof field.
115message Oneofs {
116 oneof union {
117 string str = 1;
118 Nested msg = 2;
119 }
120}
121
122// Message contains map fields.
123message Maps {
124 map<int32, string> int32_to_str = 1;
125 map<sfixed64, bool> sfixed64_to_bool = 2;
126 map<bool, uint32> bool_to_uint32 = 3;
127 map<uint64, Enum> uint64_to_enum = 4;
128 map<string, Nested> str_to_nested = 5;
129 map<string, Oneofs> str_to_oneofs = 6;
130}
131
132// Message contains well-known type fields.
133message KnownTypes {
134 optional google.protobuf.BoolValue opt_bool = 1;
135 optional google.protobuf.Int32Value opt_int32 = 2;
136 optional google.protobuf.Int64Value opt_int64 = 3;
137 optional google.protobuf.UInt32Value opt_uint32 = 4;
138 optional google.protobuf.UInt64Value opt_uint64 = 5;
139 optional google.protobuf.FloatValue opt_float = 6;
140 optional google.protobuf.DoubleValue opt_double = 7;
141 optional google.protobuf.StringValue opt_string = 8;
142 optional google.protobuf.BytesValue opt_bytes = 9;
143
144 optional google.protobuf.Duration opt_duration = 20;
145 optional google.protobuf.Timestamp opt_timestamp = 21;
146 optional google.protobuf.Struct opt_struct = 25;
147 optional google.protobuf.ListValue opt_list = 26;
148 optional google.protobuf.Value opt_value = 27;
149 optional google.protobuf.Empty opt_empty = 30;
150 optional google.protobuf.Any opt_any = 32;
151}