1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test Protobuf definitions with proto2 syntax.
syntax = "proto2";
package pb2;
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
option go_package = "google.golang.org/protobuf/internal/testprotos/textpb2";
// Scalars contains optional scalar fields.
message Scalars {
optional bool opt_bool = 1;
optional int32 opt_int32 = 2;
optional int64 opt_int64 = 3;
optional uint32 opt_uint32 = 4;
optional uint64 opt_uint64 = 5;
optional sint32 opt_sint32 = 6;
optional sint64 opt_sint64 = 7;
optional fixed32 opt_fixed32 = 8;
optional fixed64 opt_fixed64 = 9;
optional sfixed32 opt_sfixed32 = 10;
optional sfixed64 opt_sfixed64 = 11;
// Textproto marshal outputs fields in the same order as this proto
// definition regardless of field number. Following fields are intended to
// test that assumption.
optional float opt_float = 20;
optional double opt_double = 21;
optional bytes opt_bytes = 14;
optional string opt_string = 13;
}
enum Enum {
ONE = 1;
TWO = 2;
TEN = 10;
}
// Message contains enum fields.
message Enums {
optional Enum opt_enum = 1;
repeated Enum rpt_enum = 2;
enum NestedEnum {
UNO = 1;
DOS = 2;
DIEZ = 10;
}
optional NestedEnum opt_nested_enum = 3;
repeated NestedEnum rpt_nested_enum = 4;
}
// Message contains repeated fields.
message Repeats {
repeated bool rpt_bool = 1;
repeated int32 rpt_int32 = 2;
repeated int64 rpt_int64 = 3;
repeated uint32 rpt_uint32 = 4;
repeated uint64 rpt_uint64 = 5;
repeated float rpt_float = 6;
repeated double rpt_double = 7;
repeated string rpt_string = 8;
repeated bytes rpt_bytes = 9;
}
// Message contains map fields.
message Maps {
map<int32, string> int32_to_str = 1;
map<string, Nested> str_to_nested = 4;
}
// Message type used as submessage.
message Nested {
optional string opt_string = 1;
optional Nested opt_nested = 2;
}
// Message contains message and group fields.
message Nests {
optional Nested opt_nested = 1;
optional group OptGroup = 2 {
optional string opt_string = 1;
optional Nested opt_nested = 2;
optional group OptNestedGroup = 3 {
optional fixed32 opt_fixed32 = 1;
}
}
repeated Nested rpt_nested = 4;
repeated group RptGroup = 5 {
repeated string rpt_string = 1;
}
reserved "reserved_field";
}
// Message contains required fields.
message Requireds {
required bool req_bool = 1;
required sfixed64 req_sfixed64 = 2;
required double req_double = 3;
required string req_string = 4;
required Enum req_enum = 5;
required Nested req_nested = 6;
}
// Message contains both required and optional fields.
message PartialRequired {
required string req_string = 1;
optional string opt_string = 2;
}
// Following messages are for testing required field nested in optional,
// repeated and map fields.
message NestedWithRequired {
required string req_string = 1;
}
message IndirectRequired {
optional NestedWithRequired opt_nested = 1;
repeated NestedWithRequired rpt_nested = 2;
map<string, NestedWithRequired> str_to_nested = 3;
oneof union {
NestedWithRequired oneof_nested = 4;
}
}
// Following messages are for testing extensions.
message Extensions {
optional string opt_string = 1;
extensions 20 to 100;
optional bool opt_bool = 101;
optional int32 opt_int32 = 2;
}
extend Extensions {
optional bool opt_ext_bool = 21;
optional string opt_ext_string = 22;
optional Enum opt_ext_enum = 23;
optional Nested opt_ext_nested = 24;
optional PartialRequired opt_ext_partial = 25;
repeated fixed32 rpt_ext_fixed32 = 31;
repeated Enum rpt_ext_enum = 32;
repeated Nested rpt_ext_nested = 33;
}
message ExtensionsContainer {
extend Extensions {
optional bool opt_ext_bool = 51;
optional string opt_ext_string = 52;
optional Enum opt_ext_enum = 53;
optional Nested opt_ext_nested = 54;
optional PartialRequired opt_ext_partial = 55;
repeated string rpt_ext_string = 61;
repeated Enum rpt_ext_enum = 62;
repeated Nested rpt_ext_nested = 63;
}
}
// Following messages are for testing MessageSet.
message MessageSet {
option message_set_wire_format = true;
extensions 4 to max;
}
message MessageSetExtension {
optional string opt_string = 1;
extend MessageSet {
optional MessageSetExtension message_set_extension = 10;
optional MessageSetExtension not_message_set_extension = 20;
optional Nested ext_nested = 30;
}
}
message FakeMessageSet {
extensions 4 to max;
}
message FakeMessageSetExtension {
optional string opt_string = 1;
extend FakeMessageSet {
optional FakeMessageSetExtension message_set_extension = 10;
}
}
extend MessageSet {
optional FakeMessageSetExtension message_set_extension = 50;
}
// Message contains well-known type fields.
message KnownTypes {
optional google.protobuf.BoolValue opt_bool = 1;
optional google.protobuf.Int32Value opt_int32 = 2;
optional google.protobuf.Int64Value opt_int64 = 3;
optional google.protobuf.UInt32Value opt_uint32 = 4;
optional google.protobuf.UInt64Value opt_uint64 = 5;
optional google.protobuf.FloatValue opt_float = 6;
optional google.protobuf.DoubleValue opt_double = 7;
optional google.protobuf.StringValue opt_string = 8;
optional google.protobuf.BytesValue opt_bytes = 9;
optional google.protobuf.Duration opt_duration = 20;
optional google.protobuf.Timestamp opt_timestamp = 21;
optional google.protobuf.Struct opt_struct = 25;
optional google.protobuf.ListValue opt_list = 26;
optional google.protobuf.Value opt_value = 27;
optional google.protobuf.NullValue opt_null = 28;
optional google.protobuf.Empty opt_empty = 30;
optional google.protobuf.Any opt_any = 32;
optional google.protobuf.FieldMask opt_fieldmask = 40;
}
// Message contains reserved field name.
message ReservedFieldNames {
reserved "reserved_field";
optional int32 opt_int32 = 1;
}
|