Reputation: 24851
package tutorial;
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
}
What does "1", "2", "3" mean ?
Upvotes: 15
Views: 6263
Reputation:
Each field in the message definition has a unique numbered tag. These tags are used to identify your fields in the message binary format, and should not be changed once your message type is in use.
Upvotes: 13
Reputation: 1500825
They're the field numbers - they're used in the wire representation to identify which field is associated with a value. This means that renaming a field isn't a breaking change (in terms of wire format) and the names themselves don't have to be serialized.
Upvotes: 8