You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining `.proto` files, you can specify that a field is either `optional`
234
-
or `repeated` (proto2 and proto3) or leave it set to the default, implicit
235
-
presence, in proto3. (The option to set a field to `required` is absent in
236
-
proto3 and strongly discouraged in proto2. For more on this, see [Required Fields Considered Harmful](/programming-guides/required-considered-harmful.md).)
231
+
When defining `.proto` files, you can specify cardinality (singular or
232
+
repeated). In proto2 and proto3, you can also specify if the field is optional.
233
+
In proto3, setting a field to optional
234
+
[changes it from implicit presence to explicit presence](/programming-guides/field_presence).
237
235
238
-
After setting the optionality/repeatability of a field, you specify the data
239
-
type. Protocol buffers support the usual primitive data types, such as integers,
240
-
booleans, and floats. For the full list, see
236
+
After setting the cardinality of a field, you specify the data type. Protocol
237
+
buffers support the usual primitive data types, such as integers, booleans, and
238
+
floats. For the full list, see
241
239
[Scalar Value Types](/programming-guides/proto3#scalar).
242
240
243
241
A field can also be of:
@@ -249,16 +247,17 @@ A field can also be of:
249
247
and at most one field will be set at the same time.
250
248
* A `map` type, to add key-value pairs to your definition.
251
249
252
-
In proto2, messages can allow **extensions** to define fields outside of the
253
-
message, itself. For example, the protobuf library's internal message schema
254
-
allows extensions for custom, usage-specific options.
250
+
Messages can allow **extensions** to define fields outside of the message,
251
+
itself. For example, the protobuf library's internal message schema allows
252
+
extensions for custom, usage-specific options.
255
253
256
254
For more information about the options available, see the language guide for
257
-
[proto2](/programming-guides/proto2) or
258
-
[proto3](/programming-guides/proto3).
255
+
[proto2](/programming-guides/proto2),
256
+
[proto3](/programming-guides/proto3), or
257
+
[edition 2023](/programming-guides/editions).
259
258
260
-
After setting optionality and field type, you choose a name for the field.
261
-
There are some things to keep in mind when setting field names:
259
+
After setting cardinality and data type, you choose a name for the field. There
260
+
are some things to keep in mind when setting field names:
262
261
263
262
* It can sometimes be difficult, or even impossible, to change field names
264
263
after they've been used in production.
@@ -303,4 +302,4 @@ protobuf developers and users,
0 commit comments