examples/ directory in the protobuf repository contains a complete address book application that demonstrates the core Protocol Buffers workflow: define a schema, generate code, serialize data, and read it back. The same binary data file is compatible across every language, so you can write an entry with the C++ program and read it with the Python program.
The address book schema
All examples share a singleaddressbook.proto definition:
addressbook.proto
proto3 syntax and imports the well-known Timestamp type to record when a person’s entry was last modified.
Adding a person
Theadd_person program reads an address book file (creating it if it doesn’t exist), prompts for a new person’s details, appends the entry, and writes the file back.
Listing people
Thelist_people program reads an existing address book file and prints every entry to stdout.
Cross-language compatibility
Because all programs encode and decode the same binary wire format, the data files are interoperable:Building the examples
- Bazel
- Make (C++)
- Make (Python)
- Make (Java)
- Make (Go)
- Dart
Bazel 0.5.4 or newer is required. Download from bazel’s release page.