Skip to content

Commit 400f61c

Browse files
committed
Removing field
1 parent b5f566e commit 400f61c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,19 @@ protoc -I=proto --go_out=go proto/*.proto
7373
- We can add new fields, and old code will just ignore them.
7474
- Likewise, if old/new code reads unknown data, the defaults will take place.
7575
- Fields can be removed as long as the tag number is not used again in our updated message type. We may want to field instead, perhaps adding the prefix `OBSOLUTE_`, or make the tag `reserved` so that future uses of our `.proto` can't accidentially reuse the number.
76-
- For changing data types (e.g. `int32` to `int643`) we must refer to the documentations.
76+
- For changing data types (e.g. `int32` to `int643`) we must refer to the documentations.
77+
- **When removing a field, we must always `reserve` the tag and the field name!** For e.g.
78+
```proto
79+
// Original Message
80+
message Message {
81+
int32 id = 1;
82+
string first_name = 2;
83+
}
84+
85+
// Lets remove field "first_name"
86+
message Message {
87+
reserved 2; // Reserved tag number
88+
reserved "first_name"; // Reserved field name
89+
int32 id = 1;
90+
}
91+
```

0 commit comments

Comments
 (0)