Chenwei Xiao | 1bbf6f3 | 2022-06-10 06:52:50 +0800 | [diff] [blame] | 1 | // See README.md for information and build instructions. |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 2 | // |
| 3 | // Note: START and END tags are used in comments to define sections used in |
| 4 | // tutorials. They are not part of the syntax for Protocol Buffers. |
| 5 | // |
| 6 | // To get an in-depth walkthrough of this file and the related examples, see: |
| 7 | // https://developers.google.com/protocol-buffers/docs/tutorials |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 8 | |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 9 | // [START declaration] |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 10 | syntax = "proto3"; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 11 | package tutorial; |
Feng Xiao | 74bf45f | 2017-09-08 15:44:09 -0700 | [diff] [blame] | 12 | |
| 13 | import "google/protobuf/timestamp.proto"; |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 14 | // [END declaration] |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 15 | |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 16 | // [START java_declaration] |
Chris Rebert | 9d17549 | 2021-03-31 17:13:01 -0700 | [diff] [blame] | 17 | option java_multiple_files = true; |
| 18 | option java_package = "com.example.tutorial.protos"; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 19 | option java_outer_classname = "AddressBookProtos"; |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 20 | // [END java_declaration] |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 21 | |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 22 | // [START csharp_declaration] |
| 23 | option csharp_namespace = "Google.Protobuf.Examples.AddressBook"; |
| 24 | // [END csharp_declaration] |
| 25 | |
Dan Kortschak | 32af37a | 2021-04-21 00:55:58 +0930 | [diff] [blame] | 26 | // [START go_declaration] |
Damien Neil | c8dfe32 | 2021-10-21 13:27:40 -0700 | [diff] [blame] | 27 | option go_package = "github.com/protocolbuffers/protobuf/examples/go/tutorialpb"; |
Dan Kortschak | 32af37a | 2021-04-21 00:55:58 +0930 | [diff] [blame] | 28 | // [END go_declaration] |
| 29 | |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 30 | // [START messages] |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 31 | message Person { |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 32 | string name = 1; |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 33 | int32 id = 2; // Unique ID number for this person. |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 34 | string email = 3; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 35 | |
| 36 | enum PhoneType { |
| 37 | MOBILE = 0; |
| 38 | HOME = 1; |
| 39 | WORK = 2; |
| 40 | } |
| 41 | |
| 42 | message PhoneNumber { |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 43 | string number = 1; |
| 44 | PhoneType type = 2; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 47 | repeated PhoneNumber phones = 4; |
Feng Xiao | 74bf45f | 2017-09-08 15:44:09 -0700 | [diff] [blame] | 48 | |
| 49 | google.protobuf.Timestamp last_updated = 5; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | // Our address book file is just one of these. |
| 53 | message AddressBook { |
Jan Tattermusch | b0e5ba6 | 2015-07-20 15:24:08 -0700 | [diff] [blame] | 54 | repeated Person people = 1; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 55 | } |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 56 | // [END messages] |