Oneof, Maps & Well-Known Types
Model flexible and evolving data with protobuf oneof fields, maps, and the standard well-known types like Timestamp, Duration, and Any.
Beyond Plain Scalar Fields
Real schemas need more than strings and ints: mutually exclusive choices, key/value collections, and standard date/time types. Protobuf provides oneof, maps, and well-known types.
The oneof Construct
A oneof groups fields where at most one can be set at a time. Setting one clears the others, and only the active field is sent on the wire.
message Contact {
oneof method {
string email = 1;
string phone = 2;
}
}All lessons in this course
- Protobuf Best Practices
- Schema Evolution Strategies
- Custom Protobuf Options
- Oneof, Maps & Well-Known Types