1// Go support for Protocol Buffers - Google's data interchange format 2// 3// Copyright 2010 The Go Authors. All rights reserved. 4// https://github.com/golang/protobuf 5// 6// Redistribution and use in source and binary forms, with or without 7// modification, are permitted provided that the following conditions are 8// met: 9// 10// * Redistributions of source code must retain the above copyright 11// notice, this list of conditions and the following disclaimer. 12// * Redistributions in binary form must reproduce the above 13// copyright notice, this list of conditions and the following disclaimer 14// in the documentation and/or other materials provided with the 15// distribution. 16// * Neither the name of Google Inc. nor the names of its 17// contributors may be used to endorse or promote products derived from 18// this software without specific prior written permission. 19// 20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 32syntax = "proto2"; 33 34// This package holds interesting messages. 35package my.test; // dotted package name 36 37option go_package = "github.com/gogo/protobuf/protoc-gen-gogo/testdata/my_test;test"; 38 39//import "imp.proto"; 40import "multi/multi1.proto"; // unused import 41 42enum HatType { 43 // deliberately skipping 0 44 FEDORA = 1; 45 FEZ = 2; 46} 47 48// This enum represents days of the week. 49enum Days { 50 option allow_alias = true; 51 52 MONDAY = 1; 53 TUESDAY = 2; 54 LUNDI = 1; // same value as MONDAY 55} 56 57// This is a message that might be sent somewhere. 58message Request { 59 enum Color { 60 RED = 0; 61 GREEN = 1; 62 BLUE = 2; 63 } 64 repeated int64 key = 1; 65// optional imp.ImportedMessage imported_message = 2; 66 optional Color hue = 3; // no default 67 optional HatType hat = 4 [default=FEDORA]; 68// optional imp.ImportedMessage.Owner owner = 6; 69 optional float deadline = 7 [default=inf]; 70 optional group SomeGroup = 8 { 71 optional int32 group_field = 9; 72 } 73 74 // These foreign types are in imp2.proto, 75 // which is publicly imported by imp.proto. 76// optional imp.PubliclyImportedMessage pub = 10; 77// optional imp.PubliclyImportedEnum pub_enum = 13 [default=HAIR]; 78 79 80 // This is a map field. It will generate map[int32]string. 81 map<int32, string> name_mapping = 14; 82 // This is a map field whose value type is a message. 83 map<sint64, Reply> msg_mapping = 15; 84 85 optional int32 reset = 12; 86 // This field should not conflict with any getters. 87 optional string get_key = 16; 88} 89 90message Reply { 91 message Entry { 92 required int64 key_that_needs_1234camel_CasIng = 1; 93 optional int64 value = 2 [default=7]; 94 optional int64 _my_field_name_2 = 3; 95 enum Game { 96 FOOTBALL = 1; 97 TENNIS = 2; 98 } 99 } 100 repeated Entry found = 1; 101 repeated int32 compact_keys = 2 [packed=true]; 102 extensions 100 to max; 103} 104 105message OtherBase { 106 optional string name = 1; 107 extensions 100 to max; 108} 109 110message ReplyExtensions { 111 extend Reply { 112 optional double time = 101; 113 optional ReplyExtensions carrot = 105; 114 } 115 extend OtherBase { 116 optional ReplyExtensions donut = 101; 117 } 118} 119 120message OtherReplyExtensions { 121 optional int32 key = 1; 122} 123 124// top-level extension 125extend Reply { 126 optional string tag = 103; 127 optional OtherReplyExtensions donut = 106; 128// optional imp.ImportedMessage elephant = 107; // extend with message from another file. 129} 130 131message OldReply { 132 // Extensions will be encoded in MessageSet wire format. 133 option message_set_wire_format = true; 134 extensions 100 to max; 135} 136 137message Communique { 138 optional bool make_me_cry = 1; 139 140 // This is a oneof, called "union". 141 oneof union { 142 int32 number = 5; 143 string name = 6; 144 bytes data = 7; 145 double temp_c = 8; 146 float height = 9; 147 Days today = 10; 148 bool maybe = 11; 149 sint32 delta = 12; // name will conflict with Delta below 150 Reply msg = 16; // requires two bytes to encode field tag 151 group SomeGroup = 14 { 152 optional string member = 15; 153 } 154 } 155 156 message Delta {} 157} 158 159