Commit 8f79df77 authored by Jeromy's avatar Jeromy
Browse files

vendor in gogo protobuf

parent f3d96ac5
// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
// http://github.com/gogo/protobuf/gogoproto
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"fmt"
"os"
"reflect"
)
func (p *Properties) setCustomEncAndDec(typ reflect.Type) {
p.ctype = typ
if p.Repeated {
p.enc = (*Buffer).enc_custom_slice_bytes
p.dec = (*Buffer).dec_custom_slice_bytes
p.size = size_custom_slice_bytes
} else if typ.Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_custom_bytes
p.dec = (*Buffer).dec_custom_bytes
p.size = size_custom_bytes
} else {
p.enc = (*Buffer).enc_custom_ref_bytes
p.dec = (*Buffer).dec_custom_ref_bytes
p.size = size_custom_ref_bytes
}
}
func (p *Properties) setSliceOfNonPointerStructs(typ reflect.Type) {
t2 := typ.Elem()
p.sstype = typ
p.stype = t2
p.isMarshaler = isMarshaler(t2)
p.isUnmarshaler = isUnmarshaler(t2)
p.enc = (*Buffer).enc_slice_ref_struct_message
p.dec = (*Buffer).dec_slice_ref_struct_message
p.size = size_slice_ref_struct_message
if p.Wire != "bytes" {
fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T \n", typ, t2)
}
}
// Code generated by protoc-gen-gogo.
// source: proto3_proto/proto3.proto
// DO NOT EDIT!
/*
Package proto3_proto is a generated protocol buffer package.
It is generated from these files:
proto3_proto/proto3.proto
It has these top-level messages:
Message
Nested
MessageWithMap
*/
package proto3_proto
import proto "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto"
import fmt "fmt"
import math "math"
import testdata "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto/testdata"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
type Message_Humour int32
const (
Message_UNKNOWN Message_Humour = 0
Message_PUNS Message_Humour = 1
Message_SLAPSTICK Message_Humour = 2
Message_BILL_BAILEY Message_Humour = 3
)
var Message_Humour_name = map[int32]string{
0: "UNKNOWN",
1: "PUNS",
2: "SLAPSTICK",
3: "BILL_BAILEY",
}
var Message_Humour_value = map[string]int32{
"UNKNOWN": 0,
"PUNS": 1,
"SLAPSTICK": 2,
"BILL_BAILEY": 3,
}
func (x Message_Humour) String() string {
return proto.EnumName(Message_Humour_name, int32(x))
}
type Message struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Hilarity Message_Humour `protobuf:"varint,2,opt,name=hilarity,proto3,enum=proto3_proto.Message_Humour" json:"hilarity,omitempty"`
HeightInCm uint32 `protobuf:"varint,3,opt,name=height_in_cm,proto3" json:"height_in_cm,omitempty"`
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
ResultCount int64 `protobuf:"varint,7,opt,name=result_count,proto3" json:"result_count,omitempty"`
TrueScotsman bool `protobuf:"varint,8,opt,name=true_scotsman,proto3" json:"true_scotsman,omitempty"`
Score float32 `protobuf:"fixed32,9,opt,name=score,proto3" json:"score,omitempty"`
Key []uint64 `protobuf:"varint,5,rep,name=key" json:"key,omitempty"`
Nested *Nested `protobuf:"bytes,6,opt,name=nested" json:"nested,omitempty"`
Terrain map[string]*Nested `protobuf:"bytes,10,rep,name=terrain" json:"terrain,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"`
Proto2Field *testdata.SubDefaults `protobuf:"bytes,11,opt,name=proto2_field" json:"proto2_field,omitempty"`
Proto2Value map[string]*testdata.SubDefaults `protobuf:"bytes,13,rep,name=proto2_value" json:"proto2_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"`
}
func (m *Message) Reset() { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage() {}
func (m *Message) GetNested() *Nested {
if m != nil {
return m.Nested
}
return nil
}
func (m *Message) GetTerrain() map[string]*Nested {
if m != nil {
return m.Terrain
}
return nil
}
func (m *Message) GetProto2Field() *testdata.SubDefaults {
if m != nil {
return m.Proto2Field
}
return nil
}
func (m *Message) GetProto2Value() map[string]*testdata.SubDefaults {
if m != nil {
return m.Proto2Value
}
return nil
}
type Nested struct {
Bunny string `protobuf:"bytes,1,opt,name=bunny,proto3" json:"bunny,omitempty"`
}
func (m *Nested) Reset() { *m = Nested{} }
func (m *Nested) String() string { return proto.CompactTextString(m) }
func (*Nested) ProtoMessage() {}
type MessageWithMap struct {
ByteMapping map[bool][]byte `protobuf:"bytes,1,rep,name=byte_mapping" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (m *MessageWithMap) Reset() { *m = MessageWithMap{} }
func (m *MessageWithMap) String() string { return proto.CompactTextString(m) }
func (*MessageWithMap) ProtoMessage() {}
func (m *MessageWithMap) GetByteMapping() map[bool][]byte {
if m != nil {
return m.ByteMapping
}
return nil
}
func init() {
proto.RegisterEnum("proto3_proto.Message_Humour", Message_Humour_name, Message_Humour_value)
}
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2014 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto3";
package proto3_proto;
import "github.com/gogo/protobuf/proto/testdata/test.proto";
message Message {
enum Humour {
UNKNOWN = 0;
PUNS = 1;
SLAPSTICK = 2;
BILL_BAILEY = 3;
}
string name = 1;
Humour hilarity = 2;
uint32 height_in_cm = 3;
bytes data = 4;
int64 result_count = 7;
bool true_scotsman = 8;
float score = 9;
repeated uint64 key = 5;
Nested nested = 6;
map<string, Nested> terrain = 10;
testdata.SubDefaults proto2_field = 11;
map<string, testdata.SubDefaults> proto2_value = 13;
}
message Nested {
string bunny = 1;
}
message MessageWithMap {
map<bool, bytes> byte_mapping = 1;
}
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2014 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto_test
import (
"testing"
"QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto"
pb "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto/proto3_proto"
tpb "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto/testdata"
)
func TestProto3ZeroValues(t *testing.T) {
tests := []struct {
desc string
m proto.Message
}{
{"zero message", &pb.Message{}},
{"empty bytes field", &pb.Message{Data: []byte{}}},
}
for _, test := range tests {
b, err := proto.Marshal(test.m)
if err != nil {
t.Errorf("%s: proto.Marshal: %v", test.desc, err)
continue
}
if len(b) > 0 {
t.Errorf("%s: Encoding is non-empty: %q", test.desc, b)
}
}
}
func TestRoundTripProto3(t *testing.T) {
m := &pb.Message{
Name: "David", // (2 | 1<<3): 0x0a 0x05 "David"
Hilarity: pb.Message_PUNS, // (0 | 2<<3): 0x10 0x01
HeightInCm: 178, // (0 | 3<<3): 0x18 0xb2 0x01
Data: []byte("roboto"), // (2 | 4<<3): 0x20 0x06 "roboto"
ResultCount: 47, // (0 | 7<<3): 0x38 0x2f
TrueScotsman: true, // (0 | 8<<3): 0x40 0x01
Score: 8.1, // (5 | 9<<3): 0x4d <8.1>
Key: []uint64{1, 0xdeadbeef},
Nested: &pb.Nested{
Bunny: "Monty",
},
}
t.Logf(" m: %v", m)
b, err := proto.Marshal(m)
if err != nil {
t.Fatalf("proto.Marshal: %v", err)
}
t.Logf(" b: %q", b)
m2 := new(pb.Message)
if err := proto.Unmarshal(b, m2); err != nil {
t.Fatalf("proto.Unmarshal: %v", err)
}
t.Logf("m2: %v", m2)
if !proto.Equal(m, m2) {
t.Errorf("proto.Equal returned false:\n m: %v\nm2: %v", m, m2)
}
}
func TestProto3SetDefaults(t *testing.T) {
in := &pb.Message{
Terrain: map[string]*pb.Nested{
"meadow": new(pb.Nested),
},
Proto2Field: new(tpb.SubDefaults),
Proto2Value: map[string]*tpb.SubDefaults{
"badlands": new(tpb.SubDefaults),
},
}
got := proto.Clone(in).(*pb.Message)
proto.SetDefaults(got)
// There are no defaults in proto3. Everything should be the zero value, but
// we need to remember to set defaults for nested proto2 messages.
want := &pb.Message{
Terrain: map[string]*pb.Nested{
"meadow": new(pb.Nested),
},
Proto2Field: &tpb.SubDefaults{N: proto.Int64(7)},
Proto2Value: map[string]*tpb.SubDefaults{
"badlands": {N: proto.Int64(7)},
},
}
if !proto.Equal(got, want) {
t.Errorf("with in = %v\nproto.SetDefaults(in) =>\ngot %v\nwant %v", in, got, want)
}
}
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2012 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"testing"
)
// This is a separate file and package from size_test.go because that one uses
// generated messages and thus may not be in package proto without having a circular
// dependency, whereas this file tests unexported details of size.go.
func TestVarintSize(t *testing.T) {
// Check the edge cases carefully.
testCases := []struct {
n uint64
size int
}{
{0, 1},
{1, 1},
{127, 1},
{128, 2},
{16383, 2},
{16384, 3},
{1<<63 - 1, 9},
{1 << 63, 10},
}
for _, tc := range testCases {
size := sizeVarint(tc.n)
if size != tc.size {
t.Errorf("sizeVarint(%d) = %d, want %d", tc.n, size, tc.size)
}
}
}
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2012 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto_test
import (
"log"
"strings"
"testing"
. "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto"
proto3pb "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto/proto3_proto"
pb "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto/testdata"
)
var messageWithExtension1 = &pb.MyMessage{Count: Int32(7)}
// messageWithExtension2 is in equal_test.go.
var messageWithExtension3 = &pb.MyMessage{Count: Int32(8)}
func init() {
if err := SetExtension(messageWithExtension1, pb.E_Ext_More, &pb.Ext{Data: String("Abbott")}); err != nil {
log.Panicf("SetExtension: %v", err)
}
if err := SetExtension(messageWithExtension3, pb.E_Ext_More, &pb.Ext{Data: String("Costello")}); err != nil {
log.Panicf("SetExtension: %v", err)
}
// Force messageWithExtension3 to have the extension encoded.
Marshal(messageWithExtension3)
}
var SizeTests = []struct {
desc string
pb Message
}{
{"empty", &pb.OtherMessage{}},
// Basic types.
{"bool", &pb.Defaults{F_Bool: Bool(true)}},
{"int32", &pb.Defaults{F_Int32: Int32(12)}},
{"negative int32", &pb.Defaults{F_Int32: Int32(-1)}},
{"small int64", &pb.Defaults{F_Int64: Int64(1)}},
{"big int64", &pb.Defaults{F_Int64: Int64(1 << 20)}},
{"negative int64", &pb.Defaults{F_Int64: Int64(-1)}},
{"fixed32", &pb.Defaults{F_Fixed32: Uint32(71)}},
{"fixed64", &pb.Defaults{F_Fixed64: Uint64(72)}},
{"uint32", &pb.Defaults{F_Uint32: Uint32(123)}},
{"uint64", &pb.Defaults{F_Uint64: Uint64(124)}},
{"float", &pb.Defaults{F_Float: Float32(12.6)}},
{"double", &pb.Defaults{F_Double: Float64(13.9)}},
{"string", &pb.Defaults{F_String: String("niles")}},
{"bytes", &pb.Defaults{F_Bytes: []byte("wowsa")}},
{"bytes, empty", &pb.Defaults{F_Bytes: []byte{}}},
{"sint32", &pb.Defaults{F_Sint32: Int32(65)}},
{"sint64", &pb.Defaults{F_Sint64: Int64(67)}},
{"enum", &pb.Defaults{F_Enum: pb.Defaults_BLUE.Enum()}},
// Repeated.
{"empty repeated bool", &pb.MoreRepeated{Bools: []bool{}}},
{"repeated bool", &pb.MoreRepeated{Bools: []bool{false, true, true, false}}},
{"packed repeated bool", &pb.MoreRepeated{BoolsPacked: []bool{false, true, true, false, true, true, true}}},
{"repeated int32", &pb.MoreRepeated{Ints: []int32{1, 12203, 1729, -1}}},
{"repeated int32 packed", &pb.MoreRepeated{IntsPacked: []int32{1, 12203, 1729}}},
{"repeated int64 packed", &pb.MoreRepeated{Int64SPacked: []int64{
// Need enough large numbers to verify that the header is counting the number of bytes
// for the field, not the number of elements.
1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62,
1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62,
}}},
{"repeated string", &pb.MoreRepeated{Strings: []string{"r", "ken", "gri"}}},
{"repeated fixed", &pb.MoreRepeated{Fixeds: []uint32{1, 2, 3, 4}}},
// Nested.
{"nested", &pb.OldMessage{Nested: &pb.OldMessage_Nested{Name: String("whatever")}}},
{"group", &pb.GroupOld{G: &pb.GroupOld_G{X: Int32(12345)}}},
// Other things.
{"unrecognized", &pb.MoreRepeated{XXX_unrecognized: []byte{13<<3 | 0, 4}}},
{"extension (unencoded)", messageWithExtension1},
{"extension (encoded)", messageWithExtension3},
// proto3 message
{"proto3 empty", &proto3pb.Message{}},
{"proto3 bool", &proto3pb.Message{TrueScotsman: true}},
{"proto3 int64", &proto3pb.Message{ResultCount: 1}},
{"proto3 uint32", &proto3pb.Message{HeightInCm: 123}},
{"proto3 float", &proto3pb.Message{Score: 12.6}},
{"proto3 string", &proto3pb.Message{Name: "Snezana"}},
{"proto3 bytes", &proto3pb.Message{Data: []byte("wowsa")}},
{"proto3 bytes, empty", &proto3pb.Message{Data: []byte{}}},
{"proto3 enum", &proto3pb.Message{Hilarity: proto3pb.Message_PUNS}},
{"proto3 map field with empty bytes", &proto3pb.MessageWithMap{ByteMapping: map[bool][]byte{false: {}}}},
{"map field", &pb.MessageWithMap{NameMapping: map[int32]string{1: "Rob", 7: "Andrew"}}},
{"map field with message", &pb.MessageWithMap{MsgMapping: map[int64]*pb.FloatingPoint{0x7001: {F: Float64(2.0)}}}},
{"map field with bytes", &pb.MessageWithMap{ByteMapping: map[bool][]byte{true: []byte("this time for sure")}}},
{"map field with empty bytes", &pb.MessageWithMap{ByteMapping: map[bool][]byte{true: {}}}},
{"map field with big entry", &pb.MessageWithMap{NameMapping: map[int32]string{8: strings.Repeat("x", 125)}}},
{"map field with big key and val", &pb.MessageWithMap{StrToStr: map[string]string{strings.Repeat("x", 70): strings.Repeat("y", 70)}}},
{"map field with big numeric key", &pb.MessageWithMap{NameMapping: map[int32]string{0xf00d: "om nom nom"}}},
{"oneof not set", &pb.Communique{}},
{"oneof zero int32", &pb.Communique{Union: &pb.Communique_Number{Number: 0}}},
{"oneof int32", &pb.Communique{Union: &pb.Communique_Number{Number: 3}}},
{"oneof string", &pb.Communique{Union: &pb.Communique_Name{Name: "Rhythmic Fman"}}},
}
func TestSize(t *testing.T) {
for _, tc := range SizeTests {
size := Size(tc.pb)
b, err := Marshal(tc.pb)
if err != nil {
t.Errorf("%v: Marshal failed: %v", tc.desc, err)
continue
}
if size != len(b) {
t.Errorf("%v: Size(%v) = %d, want %d", tc.desc, tc.pb, size, len(b))
t.Logf("%v: bytes: %#v", tc.desc, b)
}
}
}
// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
// http://github.com/gogo/protobuf/gogoproto
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"fmt"
"io"
)
func Skip(data []byte) (n int, err error) {
l := len(data)
index := 0
for index < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if index >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[index]
index++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for {
if index >= l {
return 0, io.ErrUnexpectedEOF
}
index++
if data[index-1] < 0x80 {
break
}
}
return index, nil
case 1:
index += 8
return index, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if index >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[index]
index++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
index += length
return index, nil
case 3:
for {
var innerWire uint64
var start int = index
for shift := uint(0); ; shift += 7 {
if index >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[index]
index++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := Skip(data[start:])
if err != nil {
return 0, err
}
index = start + next
}
return index, nil
case 4:
return index, nil
case 5:
index += 4
return index, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
# Go support for Protocol Buffers - Google's data interchange format
#
# Copyright 2010 The Go Authors. All rights reserved.
# https://github.com/golang/protobuf
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
all: regenerate
regenerate:
go install github.com/gogo/protobuf/protoc-min-version
protoc-min-version --version="3.0.0" --gogo_out=. test.proto
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2012 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Verify that the compiler output for test.proto is unchanged.
package testdata
import (
"crypto/sha1"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"testing"
)
// sum returns in string form (for easy comparison) the SHA-1 hash of the named file.
func sum(t *testing.T, name string) string {
data, err := ioutil.ReadFile(name)
if err != nil {
t.Fatal(err)
}
t.Logf("sum(%q): length is %d", name, len(data))
hash := sha1.New()
_, err = hash.Write(data)
if err != nil {
t.Fatal(err)
}
return fmt.Sprintf("% x", hash.Sum(nil))
}
func run(t *testing.T, name string, args ...string) {
cmd := exec.Command(name, args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
t.Fatal(err)
}
}
func TestGolden(t *testing.T) {
// Compute the original checksum.
goldenSum := sum(t, "test.pb.go")
// Run the proto compiler.
run(t, "protoc", "--gogo_out="+os.TempDir(), "test.proto")
newFile := filepath.Join(os.TempDir(), "test.pb.go")
defer os.Remove(newFile)
// Compute the new checksum.
newSum := sum(t, newFile)
// Verify
if newSum != goldenSum {
run(t, "diff", "-u", "test.pb.go", newFile)
t.Fatal("Code generated by protoc-gen-go has changed; update test.pb.go")
}
}
// Code generated by protoc-gen-gogo.
// source: test.proto
// DO NOT EDIT!
/*
Package testdata is a generated protocol buffer package.
It is generated from these files:
test.proto
It has these top-level messages:
GoEnum
GoTestField
GoTest
GoSkipTest
NonPackedTest
PackedTest
MaxTag
OldMessage
NewMessage
InnerMessage
OtherMessage
MyMessage
Ext
DefaultsMessage
MyMessageSet
Empty
MessageList
Strings
Defaults
SubDefaults
RepeatedEnum
MoreRepeated
GroupOld
GroupNew
FloatingPoint
MessageWithMap
Communique
*/
package testdata
import proto "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
type FOO int32
const (
FOO_FOO1 FOO = 1
)
var FOO_name = map[int32]string{
1: "FOO1",
}
var FOO_value = map[string]int32{
"FOO1": 1,
}
func (x FOO) Enum() *FOO {
p := new(FOO)
*p = x
return p
}
func (x FOO) String() string {
return proto.EnumName(FOO_name, int32(x))
}
func (x *FOO) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(FOO_value, data, "FOO")
if err != nil {
return err
}
*x = FOO(value)
return nil
}
// An enum, for completeness.
type GoTest_KIND int32
const (
GoTest_VOID GoTest_KIND = 0
// Basic types
GoTest_BOOL GoTest_KIND = 1
GoTest_BYTES GoTest_KIND = 2
GoTest_FINGERPRINT GoTest_KIND = 3
GoTest_FLOAT GoTest_KIND = 4
GoTest_INT GoTest_KIND = 5
GoTest_STRING GoTest_KIND = 6
GoTest_TIME GoTest_KIND = 7
// Groupings
GoTest_TUPLE GoTest_KIND = 8
GoTest_ARRAY GoTest_KIND = 9
GoTest_MAP GoTest_KIND = 10
// Table types
GoTest_TABLE GoTest_KIND = 11
// Functions
GoTest_FUNCTION GoTest_KIND = 12
)
var GoTest_KIND_name = map[int32]string{
0: "VOID",
1: "BOOL",
2: "BYTES",
3: "FINGERPRINT",
4: "FLOAT",
5: "INT",
6: "STRING",
7: "TIME",
8: "TUPLE",
9: "ARRAY",
10: "MAP",
11: "TABLE",
12: "FUNCTION",
}
var GoTest_KIND_value = map[string]int32{
"VOID": 0,
"BOOL": 1,
"BYTES": 2,
"FINGERPRINT": 3,
"FLOAT": 4,
"INT": 5,
"STRING": 6,
"TIME": 7,
"TUPLE": 8,
"ARRAY": 9,
"MAP": 10,
"TABLE": 11,
"FUNCTION": 12,
}
func (x GoTest_KIND) Enum() *GoTest_KIND {
p := new(GoTest_KIND)
*p = x
return p
}
func (x GoTest_KIND) String() string {
return proto.EnumName(GoTest_KIND_name, int32(x))
}
func (x *GoTest_KIND) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(GoTest_KIND_value, data, "GoTest_KIND")
if err != nil {
return err
}
*x = GoTest_KIND(value)
return nil
}
type MyMessage_Color int32
const (
MyMessage_RED MyMessage_Color = 0
MyMessage_GREEN MyMessage_Color = 1
MyMessage_BLUE MyMessage_Color = 2
)
var MyMessage_Color_name = map[int32]string{
0: "RED",
1: "GREEN",
2: "BLUE",
}
var MyMessage_Color_value = map[string]int32{
"RED": 0,
"GREEN": 1,
"BLUE": 2,
}
func (x MyMessage_Color) Enum() *MyMessage_Color {
p := new(MyMessage_Color)
*p = x
return p
}
func (x MyMessage_Color) String() string {
return proto.EnumName(MyMessage_Color_name, int32(x))
}
func (x *MyMessage_Color) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(MyMessage_Color_value, data, "MyMessage_Color")
if err != nil {
return err
}
*x = MyMessage_Color(value)
return nil
}
type DefaultsMessage_DefaultsEnum int32
const (
DefaultsMessage_ZERO DefaultsMessage_DefaultsEnum = 0
DefaultsMessage_ONE DefaultsMessage_DefaultsEnum = 1
DefaultsMessage_TWO DefaultsMessage_DefaultsEnum = 2
)
var DefaultsMessage_DefaultsEnum_name = map[int32]string{
0: "ZERO",
1: "ONE",
2: "TWO",
}
var DefaultsMessage_DefaultsEnum_value = map[string]int32{
"ZERO": 0,
"ONE": 1,
"TWO": 2,
}
func (x DefaultsMessage_DefaultsEnum) Enum() *DefaultsMessage_DefaultsEnum {
p := new(DefaultsMessage_DefaultsEnum)
*p = x
return p
}
func (x DefaultsMessage_DefaultsEnum) String() string {
return proto.EnumName(DefaultsMessage_DefaultsEnum_name, int32(x))
}
func (x *DefaultsMessage_DefaultsEnum) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(DefaultsMessage_DefaultsEnum_value, data, "DefaultsMessage_DefaultsEnum")
if err != nil {
return err
}
*x = DefaultsMessage_DefaultsEnum(value)
return nil
}
type Defaults_Color int32
const (
Defaults_RED Defaults_Color = 0
Defaults_GREEN Defaults_Color = 1
Defaults_BLUE Defaults_Color = 2
)
var Defaults_Color_name = map[int32]string{
0: "RED",
1: "GREEN",
2: "BLUE",
}
var Defaults_Color_value = map[string]int32{
"RED": 0,
"GREEN": 1,
"BLUE": 2,
}
func (x Defaults_Color) Enum() *Defaults_Color {
p := new(Defaults_Color)
*p = x
return p
}
func (x Defaults_Color) String() string {
return proto.EnumName(Defaults_Color_name, int32(x))
}
func (x *Defaults_Color) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(Defaults_Color_value, data, "Defaults_Color")
if err != nil {
return err
}
*x = Defaults_Color(value)
return nil
}
type RepeatedEnum_Color int32
const (
RepeatedEnum_RED RepeatedEnum_Color = 1
)
var RepeatedEnum_Color_name = map[int32]string{
1: "RED",
}
var RepeatedEnum_Color_value = map[string]int32{
"RED": 1,
}
func (x RepeatedEnum_Color) Enum() *RepeatedEnum_Color {
p := new(RepeatedEnum_Color)
*p = x
return p
}
func (x RepeatedEnum_Color) String() string {
return proto.EnumName(RepeatedEnum_Color_name, int32(x))
}
func (x *RepeatedEnum_Color) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(RepeatedEnum_Color_value, data, "RepeatedEnum_Color")
if err != nil {
return err
}
*x = RepeatedEnum_Color(value)
return nil
}
type GoEnum struct {
Foo *FOO `protobuf:"varint,1,req,name=foo,enum=testdata.FOO" json:"foo,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoEnum) Reset() { *m = GoEnum{} }
func (m *GoEnum) String() string { return proto.CompactTextString(m) }
func (*GoEnum) ProtoMessage() {}
func (m *GoEnum) GetFoo() FOO {
if m != nil && m.Foo != nil {
return *m.Foo
}
return FOO_FOO1
}
type GoTestField struct {
Label *string `protobuf:"bytes,1,req,name=Label" json:"Label,omitempty"`
Type *string `protobuf:"bytes,2,req,name=Type" json:"Type,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTestField) Reset() { *m = GoTestField{} }
func (m *GoTestField) String() string { return proto.CompactTextString(m) }
func (*GoTestField) ProtoMessage() {}
func (m *GoTestField) GetLabel() string {
if m != nil && m.Label != nil {
return *m.Label
}
return ""
}
func (m *GoTestField) GetType() string {
if m != nil && m.Type != nil {
return *m.Type
}
return ""
}
type GoTest struct {
// Some typical parameters
Kind *GoTest_KIND `protobuf:"varint,1,req,name=Kind,enum=testdata.GoTest_KIND" json:"Kind,omitempty"`
Table *string `protobuf:"bytes,2,opt,name=Table" json:"Table,omitempty"`
Param *int32 `protobuf:"varint,3,opt,name=Param" json:"Param,omitempty"`
// Required, repeated and optional foreign fields.
RequiredField *GoTestField `protobuf:"bytes,4,req,name=RequiredField" json:"RequiredField,omitempty"`
RepeatedField []*GoTestField `protobuf:"bytes,5,rep,name=RepeatedField" json:"RepeatedField,omitempty"`
OptionalField *GoTestField `protobuf:"bytes,6,opt,name=OptionalField" json:"OptionalField,omitempty"`
// Required fields of all basic types
F_BoolRequired *bool `protobuf:"varint,10,req,name=F_Bool_required" json:"F_Bool_required,omitempty"`
F_Int32Required *int32 `protobuf:"varint,11,req,name=F_Int32_required" json:"F_Int32_required,omitempty"`
F_Int64Required *int64 `protobuf:"varint,12,req,name=F_Int64_required" json:"F_Int64_required,omitempty"`
F_Fixed32Required *uint32 `protobuf:"fixed32,13,req,name=F_Fixed32_required" json:"F_Fixed32_required,omitempty"`
F_Fixed64Required *uint64 `protobuf:"fixed64,14,req,name=F_Fixed64_required" json:"F_Fixed64_required,omitempty"`
F_Uint32Required *uint32 `protobuf:"varint,15,req,name=F_Uint32_required" json:"F_Uint32_required,omitempty"`
F_Uint64Required *uint64 `protobuf:"varint,16,req,name=F_Uint64_required" json:"F_Uint64_required,omitempty"`
F_FloatRequired *float32 `protobuf:"fixed32,17,req,name=F_Float_required" json:"F_Float_required,omitempty"`
F_DoubleRequired *float64 `protobuf:"fixed64,18,req,name=F_Double_required" json:"F_Double_required,omitempty"`
F_StringRequired *string `protobuf:"bytes,19,req,name=F_String_required" json:"F_String_required,omitempty"`
F_BytesRequired []byte `protobuf:"bytes,101,req,name=F_Bytes_required" json:"F_Bytes_required,omitempty"`
F_Sint32Required *int32 `protobuf:"zigzag32,102,req,name=F_Sint32_required" json:"F_Sint32_required,omitempty"`
F_Sint64Required *int64 `protobuf:"zigzag64,103,req,name=F_Sint64_required" json:"F_Sint64_required,omitempty"`
// Repeated fields of all basic types
F_BoolRepeated []bool `protobuf:"varint,20,rep,name=F_Bool_repeated" json:"F_Bool_repeated,omitempty"`
F_Int32Repeated []int32 `protobuf:"varint,21,rep,name=F_Int32_repeated" json:"F_Int32_repeated,omitempty"`
F_Int64Repeated []int64 `protobuf:"varint,22,rep,name=F_Int64_repeated" json:"F_Int64_repeated,omitempty"`
F_Fixed32Repeated []uint32 `protobuf:"fixed32,23,rep,name=F_Fixed32_repeated" json:"F_Fixed32_repeated,omitempty"`
F_Fixed64Repeated []uint64 `protobuf:"fixed64,24,rep,name=F_Fixed64_repeated" json:"F_Fixed64_repeated,omitempty"`
F_Uint32Repeated []uint32 `protobuf:"varint,25,rep,name=F_Uint32_repeated" json:"F_Uint32_repeated,omitempty"`
F_Uint64Repeated []uint64 `protobuf:"varint,26,rep,name=F_Uint64_repeated" json:"F_Uint64_repeated,omitempty"`
F_FloatRepeated []float32 `protobuf:"fixed32,27,rep,name=F_Float_repeated" json:"F_Float_repeated,omitempty"`
F_DoubleRepeated []float64 `protobuf:"fixed64,28,rep,name=F_Double_repeated" json:"F_Double_repeated,omitempty"`
F_StringRepeated []string `protobuf:"bytes,29,rep,name=F_String_repeated" json:"F_String_repeated,omitempty"`
F_BytesRepeated [][]byte `protobuf:"bytes,201,rep,name=F_Bytes_repeated" json:"F_Bytes_repeated,omitempty"`
F_Sint32Repeated []int32 `protobuf:"zigzag32,202,rep,name=F_Sint32_repeated" json:"F_Sint32_repeated,omitempty"`
F_Sint64Repeated []int64 `protobuf:"zigzag64,203,rep,name=F_Sint64_repeated" json:"F_Sint64_repeated,omitempty"`
// Optional fields of all basic types
F_BoolOptional *bool `protobuf:"varint,30,opt,name=F_Bool_optional" json:"F_Bool_optional,omitempty"`
F_Int32Optional *int32 `protobuf:"varint,31,opt,name=F_Int32_optional" json:"F_Int32_optional,omitempty"`
F_Int64Optional *int64 `protobuf:"varint,32,opt,name=F_Int64_optional" json:"F_Int64_optional,omitempty"`
F_Fixed32Optional *uint32 `protobuf:"fixed32,33,opt,name=F_Fixed32_optional" json:"F_Fixed32_optional,omitempty"`
F_Fixed64Optional *uint64 `protobuf:"fixed64,34,opt,name=F_Fixed64_optional" json:"F_Fixed64_optional,omitempty"`
F_Uint32Optional *uint32 `protobuf:"varint,35,opt,name=F_Uint32_optional" json:"F_Uint32_optional,omitempty"`
F_Uint64Optional *uint64 `protobuf:"varint,36,opt,name=F_Uint64_optional" json:"F_Uint64_optional,omitempty"`
F_FloatOptional *float32 `protobuf:"fixed32,37,opt,name=F_Float_optional" json:"F_Float_optional,omitempty"`
F_DoubleOptional *float64 `protobuf:"fixed64,38,opt,name=F_Double_optional" json:"F_Double_optional,omitempty"`
F_StringOptional *string `protobuf:"bytes,39,opt,name=F_String_optional" json:"F_String_optional,omitempty"`
F_BytesOptional []byte `protobuf:"bytes,301,opt,name=F_Bytes_optional" json:"F_Bytes_optional,omitempty"`
F_Sint32Optional *int32 `protobuf:"zigzag32,302,opt,name=F_Sint32_optional" json:"F_Sint32_optional,omitempty"`
F_Sint64Optional *int64 `protobuf:"zigzag64,303,opt,name=F_Sint64_optional" json:"F_Sint64_optional,omitempty"`
// Default-valued fields of all basic types
F_BoolDefaulted *bool `protobuf:"varint,40,opt,name=F_Bool_defaulted,def=1" json:"F_Bool_defaulted,omitempty"`
F_Int32Defaulted *int32 `protobuf:"varint,41,opt,name=F_Int32_defaulted,def=32" json:"F_Int32_defaulted,omitempty"`
F_Int64Defaulted *int64 `protobuf:"varint,42,opt,name=F_Int64_defaulted,def=64" json:"F_Int64_defaulted,omitempty"`
F_Fixed32Defaulted *uint32 `protobuf:"fixed32,43,opt,name=F_Fixed32_defaulted,def=320" json:"F_Fixed32_defaulted,omitempty"`
F_Fixed64Defaulted *uint64 `protobuf:"fixed64,44,opt,name=F_Fixed64_defaulted,def=640" json:"F_Fixed64_defaulted,omitempty"`
F_Uint32Defaulted *uint32 `protobuf:"varint,45,opt,name=F_Uint32_defaulted,def=3200" json:"F_Uint32_defaulted,omitempty"`
F_Uint64Defaulted *uint64 `protobuf:"varint,46,opt,name=F_Uint64_defaulted,def=6400" json:"F_Uint64_defaulted,omitempty"`
F_FloatDefaulted *float32 `protobuf:"fixed32,47,opt,name=F_Float_defaulted,def=314159" json:"F_Float_defaulted,omitempty"`
F_DoubleDefaulted *float64 `protobuf:"fixed64,48,opt,name=F_Double_defaulted,def=271828" json:"F_Double_defaulted,omitempty"`
F_StringDefaulted *string `protobuf:"bytes,49,opt,name=F_String_defaulted,def=hello, \"world!\"\n" json:"F_String_defaulted,omitempty"`
F_BytesDefaulted []byte `protobuf:"bytes,401,opt,name=F_Bytes_defaulted,def=Bignose" json:"F_Bytes_defaulted,omitempty"`
F_Sint32Defaulted *int32 `protobuf:"zigzag32,402,opt,name=F_Sint32_defaulted,def=-32" json:"F_Sint32_defaulted,omitempty"`
F_Sint64Defaulted *int64 `protobuf:"zigzag64,403,opt,name=F_Sint64_defaulted,def=-64" json:"F_Sint64_defaulted,omitempty"`
// Packed repeated fields (no string or bytes).
F_BoolRepeatedPacked []bool `protobuf:"varint,50,rep,packed,name=F_Bool_repeated_packed" json:"F_Bool_repeated_packed,omitempty"`
F_Int32RepeatedPacked []int32 `protobuf:"varint,51,rep,packed,name=F_Int32_repeated_packed" json:"F_Int32_repeated_packed,omitempty"`
F_Int64RepeatedPacked []int64 `protobuf:"varint,52,rep,packed,name=F_Int64_repeated_packed" json:"F_Int64_repeated_packed,omitempty"`
F_Fixed32RepeatedPacked []uint32 `protobuf:"fixed32,53,rep,packed,name=F_Fixed32_repeated_packed" json:"F_Fixed32_repeated_packed,omitempty"`
F_Fixed64RepeatedPacked []uint64 `protobuf:"fixed64,54,rep,packed,name=F_Fixed64_repeated_packed" json:"F_Fixed64_repeated_packed,omitempty"`
F_Uint32RepeatedPacked []uint32 `protobuf:"varint,55,rep,packed,name=F_Uint32_repeated_packed" json:"F_Uint32_repeated_packed,omitempty"`
F_Uint64RepeatedPacked []uint64 `protobuf:"varint,56,rep,packed,name=F_Uint64_repeated_packed" json:"F_Uint64_repeated_packed,omitempty"`
F_FloatRepeatedPacked []float32 `protobuf:"fixed32,57,rep,packed,name=F_Float_repeated_packed" json:"F_Float_repeated_packed,omitempty"`
F_DoubleRepeatedPacked []float64 `protobuf:"fixed64,58,rep,packed,name=F_Double_repeated_packed" json:"F_Double_repeated_packed,omitempty"`
F_Sint32RepeatedPacked []int32 `protobuf:"zigzag32,502,rep,packed,name=F_Sint32_repeated_packed" json:"F_Sint32_repeated_packed,omitempty"`
F_Sint64RepeatedPacked []int64 `protobuf:"zigzag64,503,rep,packed,name=F_Sint64_repeated_packed" json:"F_Sint64_repeated_packed,omitempty"`
Requiredgroup *GoTest_RequiredGroup `protobuf:"group,70,req,name=RequiredGroup" json:"requiredgroup,omitempty"`
Repeatedgroup []*GoTest_RepeatedGroup `protobuf:"group,80,rep,name=RepeatedGroup" json:"repeatedgroup,omitempty"`
Optionalgroup *GoTest_OptionalGroup `protobuf:"group,90,opt,name=OptionalGroup" json:"optionalgroup,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTest) Reset() { *m = GoTest{} }
func (m *GoTest) String() string { return proto.CompactTextString(m) }
func (*GoTest) ProtoMessage() {}
const Default_GoTest_F_BoolDefaulted bool = true
const Default_GoTest_F_Int32Defaulted int32 = 32
const Default_GoTest_F_Int64Defaulted int64 = 64
const Default_GoTest_F_Fixed32Defaulted uint32 = 320
const Default_GoTest_F_Fixed64Defaulted uint64 = 640
const Default_GoTest_F_Uint32Defaulted uint32 = 3200
const Default_GoTest_F_Uint64Defaulted uint64 = 6400
const Default_GoTest_F_FloatDefaulted float32 = 314159
const Default_GoTest_F_DoubleDefaulted float64 = 271828
const Default_GoTest_F_StringDefaulted string = "hello, \"world!\"\n"
var Default_GoTest_F_BytesDefaulted []byte = []byte("Bignose")
const Default_GoTest_F_Sint32Defaulted int32 = -32
const Default_GoTest_F_Sint64Defaulted int64 = -64
func (m *GoTest) GetKind() GoTest_KIND {
if m != nil && m.Kind != nil {
return *m.Kind
}
return GoTest_VOID
}
func (m *GoTest) GetTable() string {
if m != nil && m.Table != nil {
return *m.Table
}
return ""
}
func (m *GoTest) GetParam() int32 {
if m != nil && m.Param != nil {
return *m.Param
}
return 0
}
func (m *GoTest) GetRequiredField() *GoTestField {
if m != nil {
return m.RequiredField
}
return nil
}
func (m *GoTest) GetRepeatedField() []*GoTestField {
if m != nil {
return m.RepeatedField
}
return nil
}
func (m *GoTest) GetOptionalField() *GoTestField {
if m != nil {
return m.OptionalField
}
return nil
}
func (m *GoTest) GetF_BoolRequired() bool {
if m != nil && m.F_BoolRequired != nil {
return *m.F_BoolRequired
}
return false
}
func (m *GoTest) GetF_Int32Required() int32 {
if m != nil && m.F_Int32Required != nil {
return *m.F_Int32Required
}
return 0
}
func (m *GoTest) GetF_Int64Required() int64 {
if m != nil && m.F_Int64Required != nil {
return *m.F_Int64Required
}
return 0
}
func (m *GoTest) GetF_Fixed32Required() uint32 {
if m != nil && m.F_Fixed32Required != nil {
return *m.F_Fixed32Required
}
return 0
}
func (m *GoTest) GetF_Fixed64Required() uint64 {
if m != nil && m.F_Fixed64Required != nil {
return *m.F_Fixed64Required
}
return 0
}
func (m *GoTest) GetF_Uint32Required() uint32 {
if m != nil && m.F_Uint32Required != nil {
return *m.F_Uint32Required
}
return 0
}
func (m *GoTest) GetF_Uint64Required() uint64 {
if m != nil && m.F_Uint64Required != nil {
return *m.F_Uint64Required
}
return 0
}
func (m *GoTest) GetF_FloatRequired() float32 {
if m != nil && m.F_FloatRequired != nil {
return *m.F_FloatRequired
}
return 0
}
func (m *GoTest) GetF_DoubleRequired() float64 {
if m != nil && m.F_DoubleRequired != nil {
return *m.F_DoubleRequired
}
return 0
}
func (m *GoTest) GetF_StringRequired() string {
if m != nil && m.F_StringRequired != nil {
return *m.F_StringRequired
}
return ""
}
func (m *GoTest) GetF_BytesRequired() []byte {
if m != nil {
return m.F_BytesRequired
}
return nil
}
func (m *GoTest) GetF_Sint32Required() int32 {
if m != nil && m.F_Sint32Required != nil {
return *m.F_Sint32Required
}
return 0
}
func (m *GoTest) GetF_Sint64Required() int64 {
if m != nil && m.F_Sint64Required != nil {
return *m.F_Sint64Required
}
return 0
}
func (m *GoTest) GetF_BoolRepeated() []bool {
if m != nil {
return m.F_BoolRepeated
}
return nil
}
func (m *GoTest) GetF_Int32Repeated() []int32 {
if m != nil {
return m.F_Int32Repeated
}
return nil
}
func (m *GoTest) GetF_Int64Repeated() []int64 {
if m != nil {
return m.F_Int64Repeated
}
return nil
}
func (m *GoTest) GetF_Fixed32Repeated() []uint32 {
if m != nil {
return m.F_Fixed32Repeated
}
return nil
}
func (m *GoTest) GetF_Fixed64Repeated() []uint64 {
if m != nil {
return m.F_Fixed64Repeated
}
return nil
}
func (m *GoTest) GetF_Uint32Repeated() []uint32 {
if m != nil {
return m.F_Uint32Repeated
}
return nil
}
func (m *GoTest) GetF_Uint64Repeated() []uint64 {
if m != nil {
return m.F_Uint64Repeated
}
return nil
}
func (m *GoTest) GetF_FloatRepeated() []float32 {
if m != nil {
return m.F_FloatRepeated
}
return nil
}
func (m *GoTest) GetF_DoubleRepeated() []float64 {
if m != nil {
return m.F_DoubleRepeated
}
return nil
}
func (m *GoTest) GetF_StringRepeated() []string {
if m != nil {
return m.F_StringRepeated
}
return nil
}
func (m *GoTest) GetF_BytesRepeated() [][]byte {
if m != nil {
return m.F_BytesRepeated
}
return nil
}
func (m *GoTest) GetF_Sint32Repeated() []int32 {
if m != nil {
return m.F_Sint32Repeated
}
return nil
}
func (m *GoTest) GetF_Sint64Repeated() []int64 {
if m != nil {
return m.F_Sint64Repeated
}
return nil
}
func (m *GoTest) GetF_BoolOptional() bool {
if m != nil && m.F_BoolOptional != nil {
return *m.F_BoolOptional
}
return false
}
func (m *GoTest) GetF_Int32Optional() int32 {
if m != nil && m.F_Int32Optional != nil {
return *m.F_Int32Optional
}
return 0
}
func (m *GoTest) GetF_Int64Optional() int64 {
if m != nil && m.F_Int64Optional != nil {
return *m.F_Int64Optional
}
return 0
}
func (m *GoTest) GetF_Fixed32Optional() uint32 {
if m != nil && m.F_Fixed32Optional != nil {
return *m.F_Fixed32Optional
}
return 0
}
func (m *GoTest) GetF_Fixed64Optional() uint64 {
if m != nil && m.F_Fixed64Optional != nil {
return *m.F_Fixed64Optional
}
return 0
}
func (m *GoTest) GetF_Uint32Optional() uint32 {
if m != nil && m.F_Uint32Optional != nil {
return *m.F_Uint32Optional
}
return 0
}
func (m *GoTest) GetF_Uint64Optional() uint64 {
if m != nil && m.F_Uint64Optional != nil {
return *m.F_Uint64Optional
}
return 0
}
func (m *GoTest) GetF_FloatOptional() float32 {
if m != nil && m.F_FloatOptional != nil {
return *m.F_FloatOptional
}
return 0
}
func (m *GoTest) GetF_DoubleOptional() float64 {
if m != nil && m.F_DoubleOptional != nil {
return *m.F_DoubleOptional
}
return 0
}
func (m *GoTest) GetF_StringOptional() string {
if m != nil && m.F_StringOptional != nil {
return *m.F_StringOptional
}
return ""
}
func (m *GoTest) GetF_BytesOptional() []byte {
if m != nil {
return m.F_BytesOptional
}
return nil
}
func (m *GoTest) GetF_Sint32Optional() int32 {
if m != nil && m.F_Sint32Optional != nil {
return *m.F_Sint32Optional
}
return 0
}
func (m *GoTest) GetF_Sint64Optional() int64 {
if m != nil && m.F_Sint64Optional != nil {
return *m.F_Sint64Optional
}
return 0
}
func (m *GoTest) GetF_BoolDefaulted() bool {
if m != nil && m.F_BoolDefaulted != nil {
return *m.F_BoolDefaulted
}
return Default_GoTest_F_BoolDefaulted
}
func (m *GoTest) GetF_Int32Defaulted() int32 {
if m != nil && m.F_Int32Defaulted != nil {
return *m.F_Int32Defaulted
}
return Default_GoTest_F_Int32Defaulted
}
func (m *GoTest) GetF_Int64Defaulted() int64 {
if m != nil && m.F_Int64Defaulted != nil {
return *m.F_Int64Defaulted
}
return Default_GoTest_F_Int64Defaulted
}
func (m *GoTest) GetF_Fixed32Defaulted() uint32 {
if m != nil && m.F_Fixed32Defaulted != nil {
return *m.F_Fixed32Defaulted
}
return Default_GoTest_F_Fixed32Defaulted
}
func (m *GoTest) GetF_Fixed64Defaulted() uint64 {
if m != nil && m.F_Fixed64Defaulted != nil {
return *m.F_Fixed64Defaulted
}
return Default_GoTest_F_Fixed64Defaulted
}
func (m *GoTest) GetF_Uint32Defaulted() uint32 {
if m != nil && m.F_Uint32Defaulted != nil {
return *m.F_Uint32Defaulted
}
return Default_GoTest_F_Uint32Defaulted
}
func (m *GoTest) GetF_Uint64Defaulted() uint64 {
if m != nil && m.F_Uint64Defaulted != nil {
return *m.F_Uint64Defaulted
}
return Default_GoTest_F_Uint64Defaulted
}
func (m *GoTest) GetF_FloatDefaulted() float32 {
if m != nil && m.F_FloatDefaulted != nil {
return *m.F_FloatDefaulted
}
return Default_GoTest_F_FloatDefaulted
}
func (m *GoTest) GetF_DoubleDefaulted() float64 {
if m != nil && m.F_DoubleDefaulted != nil {
return *m.F_DoubleDefaulted
}
return Default_GoTest_F_DoubleDefaulted
}
func (m *GoTest) GetF_StringDefaulted() string {
if m != nil && m.F_StringDefaulted != nil {
return *m.F_StringDefaulted
}
return Default_GoTest_F_StringDefaulted
}
func (m *GoTest) GetF_BytesDefaulted() []byte {
if m != nil && m.F_BytesDefaulted != nil {
return m.F_BytesDefaulted
}
return append([]byte(nil), Default_GoTest_F_BytesDefaulted...)
}
func (m *GoTest) GetF_Sint32Defaulted() int32 {
if m != nil && m.F_Sint32Defaulted != nil {
return *m.F_Sint32Defaulted
}
return Default_GoTest_F_Sint32Defaulted
}
func (m *GoTest) GetF_Sint64Defaulted() int64 {
if m != nil && m.F_Sint64Defaulted != nil {
return *m.F_Sint64Defaulted
}
return Default_GoTest_F_Sint64Defaulted
}
func (m *GoTest) GetF_BoolRepeatedPacked() []bool {
if m != nil {
return m.F_BoolRepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Int32RepeatedPacked() []int32 {
if m != nil {
return m.F_Int32RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Int64RepeatedPacked() []int64 {
if m != nil {
return m.F_Int64RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Fixed32RepeatedPacked() []uint32 {
if m != nil {
return m.F_Fixed32RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Fixed64RepeatedPacked() []uint64 {
if m != nil {
return m.F_Fixed64RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Uint32RepeatedPacked() []uint32 {
if m != nil {
return m.F_Uint32RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Uint64RepeatedPacked() []uint64 {
if m != nil {
return m.F_Uint64RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_FloatRepeatedPacked() []float32 {
if m != nil {
return m.F_FloatRepeatedPacked
}
return nil
}
func (m *GoTest) GetF_DoubleRepeatedPacked() []float64 {
if m != nil {
return m.F_DoubleRepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Sint32RepeatedPacked() []int32 {
if m != nil {
return m.F_Sint32RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Sint64RepeatedPacked() []int64 {
if m != nil {
return m.F_Sint64RepeatedPacked
}
return nil
}
func (m *GoTest) GetRequiredgroup() *GoTest_RequiredGroup {
if m != nil {
return m.Requiredgroup
}
return nil
}
func (m *GoTest) GetRepeatedgroup() []*GoTest_RepeatedGroup {
if m != nil {
return m.Repeatedgroup
}
return nil
}
func (m *GoTest) GetOptionalgroup() *GoTest_OptionalGroup {
if m != nil {
return m.Optionalgroup
}
return nil
}
// Required, repeated, and optional groups.
type GoTest_RequiredGroup struct {
RequiredField *string `protobuf:"bytes,71,req,name=RequiredField" json:"RequiredField,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTest_RequiredGroup) Reset() { *m = GoTest_RequiredGroup{} }
func (m *GoTest_RequiredGroup) String() string { return proto.CompactTextString(m) }
func (*GoTest_RequiredGroup) ProtoMessage() {}
func (m *GoTest_RequiredGroup) GetRequiredField() string {
if m != nil && m.RequiredField != nil {
return *m.RequiredField
}
return ""
}
type GoTest_RepeatedGroup struct {
RequiredField *string `protobuf:"bytes,81,req,name=RequiredField" json:"RequiredField,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTest_RepeatedGroup) Reset() { *m = GoTest_RepeatedGroup{} }
func (m *GoTest_RepeatedGroup) String() string { return proto.CompactTextString(m) }
func (*GoTest_RepeatedGroup) ProtoMessage() {}
func (m *GoTest_RepeatedGroup) GetRequiredField() string {
if m != nil && m.RequiredField != nil {
return *m.RequiredField
}
return ""
}
type GoTest_OptionalGroup struct {
RequiredField *string `protobuf:"bytes,91,req,name=RequiredField" json:"RequiredField,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTest_OptionalGroup) Reset() { *m = GoTest_OptionalGroup{} }
func (m *GoTest_OptionalGroup) String() string { return proto.CompactTextString(m) }
func (*GoTest_OptionalGroup) ProtoMessage() {}
func (m *GoTest_OptionalGroup) GetRequiredField() string {
if m != nil && m.RequiredField != nil {
return *m.RequiredField
}
return ""
}
// For testing skipping of unrecognized fields.
// Numbers are all big, larger than tag numbers in GoTestField,
// the message used in the corresponding test.
type GoSkipTest struct {
SkipInt32 *int32 `protobuf:"varint,11,req,name=skip_int32" json:"skip_int32,omitempty"`
SkipFixed32 *uint32 `protobuf:"fixed32,12,req,name=skip_fixed32" json:"skip_fixed32,omitempty"`
SkipFixed64 *uint64 `protobuf:"fixed64,13,req,name=skip_fixed64" json:"skip_fixed64,omitempty"`
SkipString *string `protobuf:"bytes,14,req,name=skip_string" json:"skip_string,omitempty"`
Skipgroup *GoSkipTest_SkipGroup `protobuf:"group,15,req,name=SkipGroup" json:"skipgroup,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoSkipTest) Reset() { *m = GoSkipTest{} }
func (m *GoSkipTest) String() string { return proto.CompactTextString(m) }
func (*GoSkipTest) ProtoMessage() {}
func (m *GoSkipTest) GetSkipInt32() int32 {
if m != nil && m.SkipInt32 != nil {
return *m.SkipInt32
}
return 0
}
func (m *GoSkipTest) GetSkipFixed32() uint32 {
if m != nil && m.SkipFixed32 != nil {
return *m.SkipFixed32
}
return 0
}
func (m *GoSkipTest) GetSkipFixed64() uint64 {
if m != nil && m.SkipFixed64 != nil {
return *m.SkipFixed64
}
return 0
}
func (m *GoSkipTest) GetSkipString() string {
if m != nil && m.SkipString != nil {
return *m.SkipString
}
return ""
}
func (m *GoSkipTest) GetSkipgroup() *GoSkipTest_SkipGroup {
if m != nil {
return m.Skipgroup
}
return nil
}
type GoSkipTest_SkipGroup struct {
GroupInt32 *int32 `protobuf:"varint,16,req,name=group_int32" json:"group_int32,omitempty"`
GroupString *string `protobuf:"bytes,17,req,name=group_string" json:"group_string,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoSkipTest_SkipGroup) Reset() { *m = GoSkipTest_SkipGroup{} }
func (m *GoSkipTest_SkipGroup) String() string { return proto.CompactTextString(m) }
func (*GoSkipTest_SkipGroup) ProtoMessage() {}
func (m *GoSkipTest_SkipGroup) GetGroupInt32() int32 {
if m != nil && m.GroupInt32 != nil {
return *m.GroupInt32
}
return 0
}
func (m *GoSkipTest_SkipGroup) GetGroupString() string {
if m != nil && m.GroupString != nil {
return *m.GroupString
}
return ""
}
// For testing packed/non-packed decoder switching.
// A serialized instance of one should be deserializable as the other.
type NonPackedTest struct {
A []int32 `protobuf:"varint,1,rep,name=a" json:"a,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *NonPackedTest) Reset() { *m = NonPackedTest{} }
func (m *NonPackedTest) String() string { return proto.CompactTextString(m) }
func (*NonPackedTest) ProtoMessage() {}
func (m *NonPackedTest) GetA() []int32 {
if m != nil {
return m.A
}
return nil
}
type PackedTest struct {
B []int32 `protobuf:"varint,1,rep,packed,name=b" json:"b,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *PackedTest) Reset() { *m = PackedTest{} }
func (m *PackedTest) String() string { return proto.CompactTextString(m) }
func (*PackedTest) ProtoMessage() {}
func (m *PackedTest) GetB() []int32 {
if m != nil {
return m.B
}
return nil
}
type MaxTag struct {
// Maximum possible tag number.
LastField *string `protobuf:"bytes,536870911,opt,name=last_field" json:"last_field,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MaxTag) Reset() { *m = MaxTag{} }
func (m *MaxTag) String() string { return proto.CompactTextString(m) }
func (*MaxTag) ProtoMessage() {}
func (m *MaxTag) GetLastField() string {
if m != nil && m.LastField != nil {
return *m.LastField
}
return ""
}
type OldMessage struct {
Nested *OldMessage_Nested `protobuf:"bytes,1,opt,name=nested" json:"nested,omitempty"`
Num *int32 `protobuf:"varint,2,opt,name=num" json:"num,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *OldMessage) Reset() { *m = OldMessage{} }
func (m *OldMessage) String() string { return proto.CompactTextString(m) }
func (*OldMessage) ProtoMessage() {}
func (m *OldMessage) GetNested() *OldMessage_Nested {
if m != nil {
return m.Nested
}
return nil
}
func (m *OldMessage) GetNum() int32 {
if m != nil && m.Num != nil {
return *m.Num
}
return 0
}
type OldMessage_Nested struct {
Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *OldMessage_Nested) Reset() { *m = OldMessage_Nested{} }
func (m *OldMessage_Nested) String() string { return proto.CompactTextString(m) }
func (*OldMessage_Nested) ProtoMessage() {}
func (m *OldMessage_Nested) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
// NewMessage is wire compatible with OldMessage;
// imagine it as a future version.
type NewMessage struct {
Nested *NewMessage_Nested `protobuf:"bytes,1,opt,name=nested" json:"nested,omitempty"`
// This is an int32 in OldMessage.
Num *int64 `protobuf:"varint,2,opt,name=num" json:"num,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *NewMessage) Reset() { *m = NewMessage{} }
func (m *NewMessage) String() string { return proto.CompactTextString(m) }
func (*NewMessage) ProtoMessage() {}
func (m *NewMessage) GetNested() *NewMessage_Nested {
if m != nil {
return m.Nested
}
return nil
}
func (m *NewMessage) GetNum() int64 {
if m != nil && m.Num != nil {
return *m.Num
}
return 0
}
type NewMessage_Nested struct {
Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
FoodGroup *string `protobuf:"bytes,2,opt,name=food_group" json:"food_group,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *NewMessage_Nested) Reset() { *m = NewMessage_Nested{} }
func (m *NewMessage_Nested) String() string { return proto.CompactTextString(m) }
func (*NewMessage_Nested) ProtoMessage() {}
func (m *NewMessage_Nested) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
func (m *NewMessage_Nested) GetFoodGroup() string {
if m != nil && m.FoodGroup != nil {
return *m.FoodGroup
}
return ""
}
type InnerMessage struct {
Host *string `protobuf:"bytes,1,req,name=host" json:"host,omitempty"`
Port *int32 `protobuf:"varint,2,opt,name=port,def=4000" json:"port,omitempty"`
Connected *bool `protobuf:"varint,3,opt,name=connected" json:"connected,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *InnerMessage) Reset() { *m = InnerMessage{} }
func (m *InnerMessage) String() string { return proto.CompactTextString(m) }
func (*InnerMessage) ProtoMessage() {}
const Default_InnerMessage_Port int32 = 4000
func (m *InnerMessage) GetHost() string {
if m != nil && m.Host != nil {
return *m.Host
}
return ""
}
func (m *InnerMessage) GetPort() int32 {
if m != nil && m.Port != nil {
return *m.Port
}
return Default_InnerMessage_Port
}
func (m *InnerMessage) GetConnected() bool {
if m != nil && m.Connected != nil {
return *m.Connected
}
return false
}
type OtherMessage struct {
Key *int64 `protobuf:"varint,1,opt,name=key" json:"key,omitempty"`
Value []byte `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
Weight *float32 `protobuf:"fixed32,3,opt,name=weight" json:"weight,omitempty"`
Inner *InnerMessage `protobuf:"bytes,4,opt,name=inner" json:"inner,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *OtherMessage) Reset() { *m = OtherMessage{} }
func (m *OtherMessage) String() string { return proto.CompactTextString(m) }
func (*OtherMessage) ProtoMessage() {}
func (m *OtherMessage) GetKey() int64 {
if m != nil && m.Key != nil {
return *m.Key
}
return 0
}
func (m *OtherMessage) GetValue() []byte {
if m != nil {
return m.Value
}
return nil
}
func (m *OtherMessage) GetWeight() float32 {
if m != nil && m.Weight != nil {
return *m.Weight
}
return 0
}
func (m *OtherMessage) GetInner() *InnerMessage {
if m != nil {
return m.Inner
}
return nil
}
type MyMessage struct {
Count *int32 `protobuf:"varint,1,req,name=count" json:"count,omitempty"`
Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
Quote *string `protobuf:"bytes,3,opt,name=quote" json:"quote,omitempty"`
Pet []string `protobuf:"bytes,4,rep,name=pet" json:"pet,omitempty"`
Inner *InnerMessage `protobuf:"bytes,5,opt,name=inner" json:"inner,omitempty"`
Others []*OtherMessage `protobuf:"bytes,6,rep,name=others" json:"others,omitempty"`
RepInner []*InnerMessage `protobuf:"bytes,12,rep,name=rep_inner" json:"rep_inner,omitempty"`
Bikeshed *MyMessage_Color `protobuf:"varint,7,opt,name=bikeshed,enum=testdata.MyMessage_Color" json:"bikeshed,omitempty"`
Somegroup *MyMessage_SomeGroup `protobuf:"group,8,opt,name=SomeGroup" json:"somegroup,omitempty"`
// This field becomes [][]byte in the generated code.
RepBytes [][]byte `protobuf:"bytes,10,rep,name=rep_bytes" json:"rep_bytes,omitempty"`
Bigfloat *float64 `protobuf:"fixed64,11,opt,name=bigfloat" json:"bigfloat,omitempty"`
XXX_extensions map[int32]proto.Extension `json:"-"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MyMessage) Reset() { *m = MyMessage{} }
func (m *MyMessage) String() string { return proto.CompactTextString(m) }
func (*MyMessage) ProtoMessage() {}
var extRange_MyMessage = []proto.ExtensionRange{
{100, 536870911},
}
func (*MyMessage) ExtensionRangeArray() []proto.ExtensionRange {
return extRange_MyMessage
}
func (m *MyMessage) ExtensionMap() map[int32]proto.Extension {
if m.XXX_extensions == nil {
m.XXX_extensions = make(map[int32]proto.Extension)
}
return m.XXX_extensions
}
func (m *MyMessage) GetCount() int32 {
if m != nil && m.Count != nil {
return *m.Count
}
return 0
}
func (m *MyMessage) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
func (m *MyMessage) GetQuote() string {
if m != nil && m.Quote != nil {
return *m.Quote
}
return ""
}
func (m *MyMessage) GetPet() []string {
if m != nil {
return m.Pet
}
return nil
}
func (m *MyMessage) GetInner() *InnerMessage {
if m != nil {
return m.Inner
}
return nil
}
func (m *MyMessage) GetOthers() []*OtherMessage {
if m != nil {
return m.Others
}
return nil
}
func (m *MyMessage) GetRepInner() []*InnerMessage {
if m != nil {
return m.RepInner
}
return nil
}
func (m *MyMessage) GetBikeshed() MyMessage_Color {
if m != nil && m.Bikeshed != nil {
return *m.Bikeshed
}
return MyMessage_RED
}
func (m *MyMessage) GetSomegroup() *MyMessage_SomeGroup {
if m != nil {
return m.Somegroup
}
return nil
}
func (m *MyMessage) GetRepBytes() [][]byte {
if m != nil {
return m.RepBytes
}
return nil
}
func (m *MyMessage) GetBigfloat() float64 {
if m != nil && m.Bigfloat != nil {
return *m.Bigfloat
}
return 0
}
type MyMessage_SomeGroup struct {
GroupField *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MyMessage_SomeGroup) Reset() { *m = MyMessage_SomeGroup{} }
func (m *MyMessage_SomeGroup) String() string { return proto.CompactTextString(m) }
func (*MyMessage_SomeGroup) ProtoMessage() {}
func (m *MyMessage_SomeGroup) GetGroupField() int32 {
if m != nil && m.GroupField != nil {
return *m.GroupField
}
return 0
}
type Ext struct {
Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Ext) Reset() { *m = Ext{} }
func (m *Ext) String() string { return proto.CompactTextString(m) }
func (*Ext) ProtoMessage() {}
func (m *Ext) GetData() string {
if m != nil && m.Data != nil {
return *m.Data
}
return ""
}
var E_Ext_More = &proto.ExtensionDesc{
ExtendedType: (*MyMessage)(nil),
ExtensionType: (*Ext)(nil),
Field: 103,
Name: "testdata.Ext.more",
Tag: "bytes,103,opt,name=more",
}
var E_Ext_Text = &proto.ExtensionDesc{
ExtendedType: (*MyMessage)(nil),
ExtensionType: (*string)(nil),
Field: 104,
Name: "testdata.Ext.text",
Tag: "bytes,104,opt,name=text",
}
var E_Ext_Number = &proto.ExtensionDesc{
ExtendedType: (*MyMessage)(nil),
ExtensionType: (*int32)(nil),
Field: 105,
Name: "testdata.Ext.number",
Tag: "varint,105,opt,name=number",
}
type DefaultsMessage struct {
XXX_extensions map[int32]proto.Extension `json:"-"`
XXX_unrecognized []byte `json:"-"`
}
func (m *DefaultsMessage) Reset() { *m = DefaultsMessage{} }
func (m *DefaultsMessage) String() string { return proto.CompactTextString(m) }
func (*DefaultsMessage) ProtoMessage() {}
var extRange_DefaultsMessage = []proto.ExtensionRange{
{100, 536870911},
}
func (*DefaultsMessage) ExtensionRangeArray() []proto.ExtensionRange {
return extRange_DefaultsMessage
}
func (m *DefaultsMessage) ExtensionMap() map[int32]proto.Extension {
if m.XXX_extensions == nil {
m.XXX_extensions = make(map[int32]proto.Extension)
}
return m.XXX_extensions
}
type MyMessageSet struct {
XXX_extensions map[int32]proto.Extension `json:"-"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MyMessageSet) Reset() { *m = MyMessageSet{} }
func (m *MyMessageSet) String() string { return proto.CompactTextString(m) }
func (*MyMessageSet) ProtoMessage() {}
func (m *MyMessageSet) Marshal() ([]byte, error) {
return proto.MarshalMessageSet(m.ExtensionMap())
}
func (m *MyMessageSet) Unmarshal(buf []byte) error {
return proto.UnmarshalMessageSet(buf, m.ExtensionMap())
}
func (m *MyMessageSet) MarshalJSON() ([]byte, error) {
return proto.MarshalMessageSetJSON(m.XXX_extensions)
}
func (m *MyMessageSet) UnmarshalJSON(buf []byte) error {
return proto.UnmarshalMessageSetJSON(buf, m.XXX_extensions)
}
// ensure MyMessageSet satisfies proto.Marshaler and proto.Unmarshaler
var _ proto.Marshaler = (*MyMessageSet)(nil)
var _ proto.Unmarshaler = (*MyMessageSet)(nil)
var extRange_MyMessageSet = []proto.ExtensionRange{
{100, 2147483646},
}
func (*MyMessageSet) ExtensionRangeArray() []proto.ExtensionRange {
return extRange_MyMessageSet
}
func (m *MyMessageSet) ExtensionMap() map[int32]proto.Extension {
if m.XXX_extensions == nil {
m.XXX_extensions = make(map[int32]proto.Extension)
}
return m.XXX_extensions
}
type Empty struct {
XXX_unrecognized []byte `json:"-"`
}
func (m *Empty) Reset() { *m = Empty{} }
func (m *Empty) String() string { return proto.CompactTextString(m) }
func (*Empty) ProtoMessage() {}
type MessageList struct {
Message []*MessageList_Message `protobuf:"group,1,rep,name=Message" json:"message,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MessageList) Reset() { *m = MessageList{} }
func (m *MessageList) String() string { return proto.CompactTextString(m) }
func (*MessageList) ProtoMessage() {}
func (m *MessageList) GetMessage() []*MessageList_Message {
if m != nil {
return m.Message
}
return nil
}
type MessageList_Message struct {
Name *string `protobuf:"bytes,2,req,name=name" json:"name,omitempty"`
Count *int32 `protobuf:"varint,3,req,name=count" json:"count,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MessageList_Message) Reset() { *m = MessageList_Message{} }
func (m *MessageList_Message) String() string { return proto.CompactTextString(m) }
func (*MessageList_Message) ProtoMessage() {}
func (m *MessageList_Message) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
func (m *MessageList_Message) GetCount() int32 {
if m != nil && m.Count != nil {
return *m.Count
}
return 0
}
type Strings struct {
StringField *string `protobuf:"bytes,1,opt,name=string_field" json:"string_field,omitempty"`
BytesField []byte `protobuf:"bytes,2,opt,name=bytes_field" json:"bytes_field,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Strings) Reset() { *m = Strings{} }
func (m *Strings) String() string { return proto.CompactTextString(m) }
func (*Strings) ProtoMessage() {}
func (m *Strings) GetStringField() string {
if m != nil && m.StringField != nil {
return *m.StringField
}
return ""
}
func (m *Strings) GetBytesField() []byte {
if m != nil {
return m.BytesField
}
return nil
}
type Defaults struct {
// Default-valued fields of all basic types.
// Same as GoTest, but copied here to make testing easier.
F_Bool *bool `protobuf:"varint,1,opt,name=F_Bool,def=1" json:"F_Bool,omitempty"`
F_Int32 *int32 `protobuf:"varint,2,opt,name=F_Int32,def=32" json:"F_Int32,omitempty"`
F_Int64 *int64 `protobuf:"varint,3,opt,name=F_Int64,def=64" json:"F_Int64,omitempty"`
F_Fixed32 *uint32 `protobuf:"fixed32,4,opt,name=F_Fixed32,def=320" json:"F_Fixed32,omitempty"`
F_Fixed64 *uint64 `protobuf:"fixed64,5,opt,name=F_Fixed64,def=640" json:"F_Fixed64,omitempty"`
F_Uint32 *uint32 `protobuf:"varint,6,opt,name=F_Uint32,def=3200" json:"F_Uint32,omitempty"`
F_Uint64 *uint64 `protobuf:"varint,7,opt,name=F_Uint64,def=6400" json:"F_Uint64,omitempty"`
F_Float *float32 `protobuf:"fixed32,8,opt,name=F_Float,def=314159" json:"F_Float,omitempty"`
F_Double *float64 `protobuf:"fixed64,9,opt,name=F_Double,def=271828" json:"F_Double,omitempty"`
F_String *string `protobuf:"bytes,10,opt,name=F_String,def=hello, \"world!\"\n" json:"F_String,omitempty"`
F_Bytes []byte `protobuf:"bytes,11,opt,name=F_Bytes,def=Bignose" json:"F_Bytes,omitempty"`
F_Sint32 *int32 `protobuf:"zigzag32,12,opt,name=F_Sint32,def=-32" json:"F_Sint32,omitempty"`
F_Sint64 *int64 `protobuf:"zigzag64,13,opt,name=F_Sint64,def=-64" json:"F_Sint64,omitempty"`
F_Enum *Defaults_Color `protobuf:"varint,14,opt,name=F_Enum,enum=testdata.Defaults_Color,def=1" json:"F_Enum,omitempty"`
// More fields with crazy defaults.
F_Pinf *float32 `protobuf:"fixed32,15,opt,name=F_Pinf,def=inf" json:"F_Pinf,omitempty"`
F_Ninf *float32 `protobuf:"fixed32,16,opt,name=F_Ninf,def=-inf" json:"F_Ninf,omitempty"`
F_Nan *float32 `protobuf:"fixed32,17,opt,name=F_Nan,def=nan" json:"F_Nan,omitempty"`
// Sub-message.
Sub *SubDefaults `protobuf:"bytes,18,opt,name=sub" json:"sub,omitempty"`
// Redundant but explicit defaults.
StrZero *string `protobuf:"bytes,19,opt,name=str_zero,def=" json:"str_zero,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Defaults) Reset() { *m = Defaults{} }
func (m *Defaults) String() string { return proto.CompactTextString(m) }
func (*Defaults) ProtoMessage() {}
const Default_Defaults_F_Bool bool = true
const Default_Defaults_F_Int32 int32 = 32
const Default_Defaults_F_Int64 int64 = 64
const Default_Defaults_F_Fixed32 uint32 = 320
const Default_Defaults_F_Fixed64 uint64 = 640
const Default_Defaults_F_Uint32 uint32 = 3200
const Default_Defaults_F_Uint64 uint64 = 6400
const Default_Defaults_F_Float float32 = 314159
const Default_Defaults_F_Double float64 = 271828
const Default_Defaults_F_String string = "hello, \"world!\"\n"
var Default_Defaults_F_Bytes []byte = []byte("Bignose")
const Default_Defaults_F_Sint32 int32 = -32
const Default_Defaults_F_Sint64 int64 = -64
const Default_Defaults_F_Enum Defaults_Color = Defaults_GREEN
var Default_Defaults_F_Pinf float32 = float32(math.Inf(1))
var Default_Defaults_F_Ninf float32 = float32(math.Inf(-1))
var Default_Defaults_F_Nan float32 = float32(math.NaN())
func (m *Defaults) GetF_Bool() bool {
if m != nil && m.F_Bool != nil {
return *m.F_Bool
}
return Default_Defaults_F_Bool
}
func (m *Defaults) GetF_Int32() int32 {
if m != nil && m.F_Int32 != nil {
return *m.F_Int32
}
return Default_Defaults_F_Int32
}
func (m *Defaults) GetF_Int64() int64 {
if m != nil && m.F_Int64 != nil {
return *m.F_Int64
}
return Default_Defaults_F_Int64
}
func (m *Defaults) GetF_Fixed32() uint32 {
if m != nil && m.F_Fixed32 != nil {
return *m.F_Fixed32
}
return Default_Defaults_F_Fixed32
}
func (m *Defaults) GetF_Fixed64() uint64 {
if m != nil && m.F_Fixed64 != nil {
return *m.F_Fixed64
}
return Default_Defaults_F_Fixed64
}
func (m *Defaults) GetF_Uint32() uint32 {
if m != nil && m.F_Uint32 != nil {
return *m.F_Uint32
}
return Default_Defaults_F_Uint32
}
func (m *Defaults) GetF_Uint64() uint64 {
if m != nil && m.F_Uint64 != nil {
return *m.F_Uint64
}
return Default_Defaults_F_Uint64
}
func (m *Defaults) GetF_Float() float32 {
if m != nil && m.F_Float != nil {
return *m.F_Float
}
return Default_Defaults_F_Float
}
func (m *Defaults) GetF_Double() float64 {
if m != nil && m.F_Double != nil {
return *m.F_Double
}
return Default_Defaults_F_Double
}
func (m *Defaults) GetF_String() string {
if m != nil && m.F_String != nil {
return *m.F_String
}
return Default_Defaults_F_String
}
func (m *Defaults) GetF_Bytes() []byte {
if m != nil && m.F_Bytes != nil {
return m.F_Bytes
}
return append([]byte(nil), Default_Defaults_F_Bytes...)
}
func (m *Defaults) GetF_Sint32() int32 {
if m != nil && m.F_Sint32 != nil {
return *m.F_Sint32
}
return Default_Defaults_F_Sint32
}
func (m *Defaults) GetF_Sint64() int64 {
if m != nil && m.F_Sint64 != nil {
return *m.F_Sint64
}
return Default_Defaults_F_Sint64
}
func (m *Defaults) GetF_Enum() Defaults_Color {
if m != nil && m.F_Enum != nil {
return *m.F_Enum
}
return Default_Defaults_F_Enum
}
func (m *Defaults) GetF_Pinf() float32 {
if m != nil && m.F_Pinf != nil {
return *m.F_Pinf
}
return Default_Defaults_F_Pinf
}
func (m *Defaults) GetF_Ninf() float32 {
if m != nil && m.F_Ninf != nil {
return *m.F_Ninf
}
return Default_Defaults_F_Ninf
}
func (m *Defaults) GetF_Nan() float32 {
if m != nil && m.F_Nan != nil {
return *m.F_Nan
}
return Default_Defaults_F_Nan
}
func (m *Defaults) GetSub() *SubDefaults {
if m != nil {
return m.Sub
}
return nil
}
func (m *Defaults) GetStrZero() string {
if m != nil && m.StrZero != nil {
return *m.StrZero
}
return ""
}
type SubDefaults struct {
N *int64 `protobuf:"varint,1,opt,name=n,def=7" json:"n,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *SubDefaults) Reset() { *m = SubDefaults{} }
func (m *SubDefaults) String() string { return proto.CompactTextString(m) }
func (*SubDefaults) ProtoMessage() {}
const Default_SubDefaults_N int64 = 7
func (m *SubDefaults) GetN() int64 {
if m != nil && m.N != nil {
return *m.N
}
return Default_SubDefaults_N
}
type RepeatedEnum struct {
Color []RepeatedEnum_Color `protobuf:"varint,1,rep,name=color,enum=testdata.RepeatedEnum_Color" json:"color,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *RepeatedEnum) Reset() { *m = RepeatedEnum{} }
func (m *RepeatedEnum) String() string { return proto.CompactTextString(m) }
func (*RepeatedEnum) ProtoMessage() {}
func (m *RepeatedEnum) GetColor() []RepeatedEnum_Color {
if m != nil {
return m.Color
}
return nil
}
type MoreRepeated struct {
Bools []bool `protobuf:"varint,1,rep,name=bools" json:"bools,omitempty"`
BoolsPacked []bool `protobuf:"varint,2,rep,packed,name=bools_packed" json:"bools_packed,omitempty"`
Ints []int32 `protobuf:"varint,3,rep,name=ints" json:"ints,omitempty"`
IntsPacked []int32 `protobuf:"varint,4,rep,packed,name=ints_packed" json:"ints_packed,omitempty"`
Int64SPacked []int64 `protobuf:"varint,7,rep,packed,name=int64s_packed" json:"int64s_packed,omitempty"`
Strings []string `protobuf:"bytes,5,rep,name=strings" json:"strings,omitempty"`
Fixeds []uint32 `protobuf:"fixed32,6,rep,name=fixeds" json:"fixeds,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MoreRepeated) Reset() { *m = MoreRepeated{} }
func (m *MoreRepeated) String() string { return proto.CompactTextString(m) }
func (*MoreRepeated) ProtoMessage() {}
func (m *MoreRepeated) GetBools() []bool {
if m != nil {
return m.Bools
}
return nil
}
func (m *MoreRepeated) GetBoolsPacked() []bool {
if m != nil {
return m.BoolsPacked
}
return nil
}
func (m *MoreRepeated) GetInts() []int32 {
if m != nil {
return m.Ints
}
return nil
}
func (m *MoreRepeated) GetIntsPacked() []int32 {
if m != nil {
return m.IntsPacked
}
return nil
}
func (m *MoreRepeated) GetInt64SPacked() []int64 {
if m != nil {
return m.Int64SPacked
}
return nil
}
func (m *MoreRepeated) GetStrings() []string {
if m != nil {
return m.Strings
}
return nil
}
func (m *MoreRepeated) GetFixeds() []uint32 {
if m != nil {
return m.Fixeds
}
return nil
}
type GroupOld struct {
G *GroupOld_G `protobuf:"group,101,opt,name=G" json:"g,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GroupOld) Reset() { *m = GroupOld{} }
func (m *GroupOld) String() string { return proto.CompactTextString(m) }
func (*GroupOld) ProtoMessage() {}
func (m *GroupOld) GetG() *GroupOld_G {
if m != nil {
return m.G
}
return nil
}
type GroupOld_G struct {
X *int32 `protobuf:"varint,2,opt,name=x" json:"x,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GroupOld_G) Reset() { *m = GroupOld_G{} }
func (m *GroupOld_G) String() string { return proto.CompactTextString(m) }
func (*GroupOld_G) ProtoMessage() {}
func (m *GroupOld_G) GetX() int32 {
if m != nil && m.X != nil {
return *m.X
}
return 0
}
type GroupNew struct {
G *GroupNew_G `protobuf:"group,101,opt,name=G" json:"g,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GroupNew) Reset() { *m = GroupNew{} }
func (m *GroupNew) String() string { return proto.CompactTextString(m) }
func (*GroupNew) ProtoMessage() {}
func (m *GroupNew) GetG() *GroupNew_G {
if m != nil {
return m.G
}
return nil
}
type GroupNew_G struct {
X *int32 `protobuf:"varint,2,opt,name=x" json:"x,omitempty"`
Y *int32 `protobuf:"varint,3,opt,name=y" json:"y,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GroupNew_G) Reset() { *m = GroupNew_G{} }
func (m *GroupNew_G) String() string { return proto.CompactTextString(m) }
func (*GroupNew_G) ProtoMessage() {}
func (m *GroupNew_G) GetX() int32 {
if m != nil && m.X != nil {
return *m.X
}
return 0
}
func (m *GroupNew_G) GetY() int32 {
if m != nil && m.Y != nil {
return *m.Y
}
return 0
}
type FloatingPoint struct {
F *float64 `protobuf:"fixed64,1,req,name=f" json:"f,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *FloatingPoint) Reset() { *m = FloatingPoint{} }
func (m *FloatingPoint) String() string { return proto.CompactTextString(m) }
func (*FloatingPoint) ProtoMessage() {}
func (m *FloatingPoint) GetF() float64 {
if m != nil && m.F != nil {
return *m.F
}
return 0
}
type MessageWithMap struct {
NameMapping map[int32]string `protobuf:"bytes,1,rep,name=name_mapping" json:"name_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
MsgMapping map[int64]*FloatingPoint `protobuf:"bytes,2,rep,name=msg_mapping" json:"msg_mapping,omitempty" protobuf_key:"zigzag64,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
ByteMapping map[bool][]byte `protobuf:"bytes,3,rep,name=byte_mapping" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
StrToStr map[string]string `protobuf:"bytes,4,rep,name=str_to_str" json:"str_to_str,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MessageWithMap) Reset() { *m = MessageWithMap{} }
func (m *MessageWithMap) String() string { return proto.CompactTextString(m) }
func (*MessageWithMap) ProtoMessage() {}
func (m *MessageWithMap) GetNameMapping() map[int32]string {
if m != nil {
return m.NameMapping
}
return nil
}
func (m *MessageWithMap) GetMsgMapping() map[int64]*FloatingPoint {
if m != nil {
return m.MsgMapping
}
return nil
}
func (m *MessageWithMap) GetByteMapping() map[bool][]byte {
if m != nil {
return m.ByteMapping
}
return nil
}
func (m *MessageWithMap) GetStrToStr() map[string]string {
if m != nil {
return m.StrToStr
}
return nil
}
type Communique struct {
MakeMeCry *bool `protobuf:"varint,1,opt,name=make_me_cry" json:"make_me_cry,omitempty"`
// This is a oneof, called "union".
//
// Types that are valid to be assigned to Union:
// *Communique_Number
// *Communique_Name
// *Communique_Data
// *Communique_TempC
// *Communique_Col
// *Communique_Msg
Union isCommunique_Union `protobuf_oneof:"union"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Communique) Reset() { *m = Communique{} }
func (m *Communique) String() string { return proto.CompactTextString(m) }
func (*Communique) ProtoMessage() {}
type isCommunique_Union interface {
isCommunique_Union()
}
type Communique_Number struct {
Number int32 `protobuf:"varint,5,opt,name=number,oneof"`
}
type Communique_Name struct {
Name string `protobuf:"bytes,6,opt,name=name,oneof"`
}
type Communique_Data struct {
Data []byte `protobuf:"bytes,7,opt,name=data,oneof"`
}
type Communique_TempC struct {
TempC float64 `protobuf:"fixed64,8,opt,name=temp_c,oneof"`
}
type Communique_Col struct {
Col MyMessage_Color `protobuf:"varint,9,opt,name=col,enum=testdata.MyMessage_Color,oneof"`
}
type Communique_Msg struct {
Msg *Strings `protobuf:"bytes,10,opt,name=msg,oneof"`
}
func (*Communique_Number) isCommunique_Union() {}
func (*Communique_Name) isCommunique_Union() {}
func (*Communique_Data) isCommunique_Union() {}
func (*Communique_TempC) isCommunique_Union() {}
func (*Communique_Col) isCommunique_Union() {}
func (*Communique_Msg) isCommunique_Union() {}
func (m *Communique) GetUnion() isCommunique_Union {
if m != nil {
return m.Union
}
return nil
}
func (m *Communique) GetMakeMeCry() bool {
if m != nil && m.MakeMeCry != nil {
return *m.MakeMeCry
}
return false
}
func (m *Communique) GetNumber() int32 {
if x, ok := m.GetUnion().(*Communique_Number); ok {
return x.Number
}
return 0
}
func (m *Communique) GetName() string {
if x, ok := m.GetUnion().(*Communique_Name); ok {
return x.Name
}
return ""
}
func (m *Communique) GetData() []byte {
if x, ok := m.GetUnion().(*Communique_Data); ok {
return x.Data
}
return nil
}
func (m *Communique) GetTempC() float64 {
if x, ok := m.GetUnion().(*Communique_TempC); ok {
return x.TempC
}
return 0
}
func (m *Communique) GetCol() MyMessage_Color {
if x, ok := m.GetUnion().(*Communique_Col); ok {
return x.Col
}
return MyMessage_RED
}
func (m *Communique) GetMsg() *Strings {
if x, ok := m.GetUnion().(*Communique_Msg); ok {
return x.Msg
}
return nil
}
// XXX_OneofFuncs is for the internal use of the proto package.
func (*Communique) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), []interface{}) {
return _Communique_OneofMarshaler, _Communique_OneofUnmarshaler, []interface{}{
(*Communique_Number)(nil),
(*Communique_Name)(nil),
(*Communique_Data)(nil),
(*Communique_TempC)(nil),
(*Communique_Col)(nil),
(*Communique_Msg)(nil),
}
}
func _Communique_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*Communique)
// union
switch x := m.Union.(type) {
case *Communique_Number:
_ = b.EncodeVarint(5<<3 | proto.WireVarint)
_ = b.EncodeVarint(uint64(x.Number))
case *Communique_Name:
_ = b.EncodeVarint(6<<3 | proto.WireBytes)
_ = b.EncodeStringBytes(x.Name)
case *Communique_Data:
_ = b.EncodeVarint(7<<3 | proto.WireBytes)
_ = b.EncodeRawBytes(x.Data)
case *Communique_TempC:
_ = b.EncodeVarint(8<<3 | proto.WireFixed64)
_ = b.EncodeFixed64(math.Float64bits(x.TempC))
case *Communique_Col:
_ = b.EncodeVarint(9<<3 | proto.WireVarint)
_ = b.EncodeVarint(uint64(x.Col))
case *Communique_Msg:
_ = b.EncodeVarint(10<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.Msg); err != nil {
return err
}
case nil:
default:
return fmt.Errorf("Communique.Union has unexpected type %T", x)
}
return nil
}
func _Communique_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Communique)
switch tag {
case 5: // union.number
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Union = &Communique_Number{int32(x)}
return true, err
case 6: // union.name
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Union = &Communique_Name{x}
return true, err
case 7: // union.data
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Union = &Communique_Data{x}
return true, err
case 8: // union.temp_c
if wire != proto.WireFixed64 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed64()
m.Union = &Communique_TempC{math.Float64frombits(x)}
return true, err
case 9: // union.col
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Union = &Communique_Col{MyMessage_Color(x)}
return true, err
case 10: // union.msg
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Strings)
err := b.DecodeMessage(msg)
m.Union = &Communique_Msg{msg}
return true, err
default:
return false, nil
}
}
var E_Greeting = &proto.ExtensionDesc{
ExtendedType: (*MyMessage)(nil),
ExtensionType: ([]string)(nil),
Field: 106,
Name: "testdata.greeting",
Tag: "bytes,106,rep,name=greeting",
}
var E_NoDefaultDouble = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*float64)(nil),
Field: 101,
Name: "testdata.no_default_double",
Tag: "fixed64,101,opt,name=no_default_double",
}
var E_NoDefaultFloat = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*float32)(nil),
Field: 102,
Name: "testdata.no_default_float",
Tag: "fixed32,102,opt,name=no_default_float",
}
var E_NoDefaultInt32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int32)(nil),
Field: 103,
Name: "testdata.no_default_int32",
Tag: "varint,103,opt,name=no_default_int32",
}
var E_NoDefaultInt64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int64)(nil),
Field: 104,
Name: "testdata.no_default_int64",
Tag: "varint,104,opt,name=no_default_int64",
}
var E_NoDefaultUint32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*uint32)(nil),
Field: 105,
Name: "testdata.no_default_uint32",
Tag: "varint,105,opt,name=no_default_uint32",
}
var E_NoDefaultUint64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*uint64)(nil),
Field: 106,
Name: "testdata.no_default_uint64",
Tag: "varint,106,opt,name=no_default_uint64",
}
var E_NoDefaultSint32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int32)(nil),
Field: 107,
Name: "testdata.no_default_sint32",
Tag: "zigzag32,107,opt,name=no_default_sint32",
}
var E_NoDefaultSint64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int64)(nil),
Field: 108,
Name: "testdata.no_default_sint64",
Tag: "zigzag64,108,opt,name=no_default_sint64",
}
var E_NoDefaultFixed32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*uint32)(nil),
Field: 109,
Name: "testdata.no_default_fixed32",
Tag: "fixed32,109,opt,name=no_default_fixed32",
}
var E_NoDefaultFixed64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*uint64)(nil),
Field: 110,
Name: "testdata.no_default_fixed64",
Tag: "fixed64,110,opt,name=no_default_fixed64",
}
var E_NoDefaultSfixed32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int32)(nil),
Field: 111,
Name: "testdata.no_default_sfixed32",
Tag: "fixed32,111,opt,name=no_default_sfixed32",
}
var E_NoDefaultSfixed64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int64)(nil),
Field: 112,
Name: "testdata.no_default_sfixed64",
Tag: "fixed64,112,opt,name=no_default_sfixed64",
}
var E_NoDefaultBool = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*bool)(nil),
Field: 113,
Name: "testdata.no_default_bool",
Tag: "varint,113,opt,name=no_default_bool",
}
var E_NoDefaultString = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*string)(nil),
Field: 114,
Name: "testdata.no_default_string",
Tag: "bytes,114,opt,name=no_default_string",
}
var E_NoDefaultBytes = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: ([]byte)(nil),
Field: 115,
Name: "testdata.no_default_bytes",
Tag: "bytes,115,opt,name=no_default_bytes",
}
var E_NoDefaultEnum = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*DefaultsMessage_DefaultsEnum)(nil),
Field: 116,
Name: "testdata.no_default_enum",
Tag: "varint,116,opt,name=no_default_enum,enum=testdata.DefaultsMessage_DefaultsEnum",
}
var E_DefaultDouble = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*float64)(nil),
Field: 201,
Name: "testdata.default_double",
Tag: "fixed64,201,opt,name=default_double,def=3.1415",
}
var E_DefaultFloat = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*float32)(nil),
Field: 202,
Name: "testdata.default_float",
Tag: "fixed32,202,opt,name=default_float,def=3.14",
}
var E_DefaultInt32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int32)(nil),
Field: 203,
Name: "testdata.default_int32",
Tag: "varint,203,opt,name=default_int32,def=42",
}
var E_DefaultInt64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int64)(nil),
Field: 204,
Name: "testdata.default_int64",
Tag: "varint,204,opt,name=default_int64,def=43",
}
var E_DefaultUint32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*uint32)(nil),
Field: 205,
Name: "testdata.default_uint32",
Tag: "varint,205,opt,name=default_uint32,def=44",
}
var E_DefaultUint64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*uint64)(nil),
Field: 206,
Name: "testdata.default_uint64",
Tag: "varint,206,opt,name=default_uint64,def=45",
}
var E_DefaultSint32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int32)(nil),
Field: 207,
Name: "testdata.default_sint32",
Tag: "zigzag32,207,opt,name=default_sint32,def=46",
}
var E_DefaultSint64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int64)(nil),
Field: 208,
Name: "testdata.default_sint64",
Tag: "zigzag64,208,opt,name=default_sint64,def=47",
}
var E_DefaultFixed32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*uint32)(nil),
Field: 209,
Name: "testdata.default_fixed32",
Tag: "fixed32,209,opt,name=default_fixed32,def=48",
}
var E_DefaultFixed64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*uint64)(nil),
Field: 210,
Name: "testdata.default_fixed64",
Tag: "fixed64,210,opt,name=default_fixed64,def=49",
}
var E_DefaultSfixed32 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int32)(nil),
Field: 211,
Name: "testdata.default_sfixed32",
Tag: "fixed32,211,opt,name=default_sfixed32,def=50",
}
var E_DefaultSfixed64 = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*int64)(nil),
Field: 212,
Name: "testdata.default_sfixed64",
Tag: "fixed64,212,opt,name=default_sfixed64,def=51",
}
var E_DefaultBool = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*bool)(nil),
Field: 213,
Name: "testdata.default_bool",
Tag: "varint,213,opt,name=default_bool,def=1",
}
var E_DefaultString = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*string)(nil),
Field: 214,
Name: "testdata.default_string",
Tag: "bytes,214,opt,name=default_string,def=Hello, string",
}
var E_DefaultBytes = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: ([]byte)(nil),
Field: 215,
Name: "testdata.default_bytes",
Tag: "bytes,215,opt,name=default_bytes,def=Hello, bytes",
}
var E_DefaultEnum = &proto.ExtensionDesc{
ExtendedType: (*DefaultsMessage)(nil),
ExtensionType: (*DefaultsMessage_DefaultsEnum)(nil),
Field: 216,
Name: "testdata.default_enum",
Tag: "varint,216,opt,name=default_enum,enum=testdata.DefaultsMessage_DefaultsEnum,def=1",
}
var E_X201 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 201,
Name: "testdata.x201",
Tag: "bytes,201,opt,name=x201",
}
var E_X202 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 202,
Name: "testdata.x202",
Tag: "bytes,202,opt,name=x202",
}
var E_X203 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 203,
Name: "testdata.x203",
Tag: "bytes,203,opt,name=x203",
}
var E_X204 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 204,
Name: "testdata.x204",
Tag: "bytes,204,opt,name=x204",
}
var E_X205 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 205,
Name: "testdata.x205",
Tag: "bytes,205,opt,name=x205",
}
var E_X206 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 206,
Name: "testdata.x206",
Tag: "bytes,206,opt,name=x206",
}
var E_X207 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 207,
Name: "testdata.x207",
Tag: "bytes,207,opt,name=x207",
}
var E_X208 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 208,
Name: "testdata.x208",
Tag: "bytes,208,opt,name=x208",
}
var E_X209 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 209,
Name: "testdata.x209",
Tag: "bytes,209,opt,name=x209",
}
var E_X210 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 210,
Name: "testdata.x210",
Tag: "bytes,210,opt,name=x210",
}
var E_X211 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 211,
Name: "testdata.x211",
Tag: "bytes,211,opt,name=x211",
}
var E_X212 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 212,
Name: "testdata.x212",
Tag: "bytes,212,opt,name=x212",
}
var E_X213 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 213,
Name: "testdata.x213",
Tag: "bytes,213,opt,name=x213",
}
var E_X214 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 214,
Name: "testdata.x214",
Tag: "bytes,214,opt,name=x214",
}
var E_X215 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 215,
Name: "testdata.x215",
Tag: "bytes,215,opt,name=x215",
}
var E_X216 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 216,
Name: "testdata.x216",
Tag: "bytes,216,opt,name=x216",
}
var E_X217 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 217,
Name: "testdata.x217",
Tag: "bytes,217,opt,name=x217",
}
var E_X218 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 218,
Name: "testdata.x218",
Tag: "bytes,218,opt,name=x218",
}
var E_X219 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 219,
Name: "testdata.x219",
Tag: "bytes,219,opt,name=x219",
}
var E_X220 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 220,
Name: "testdata.x220",
Tag: "bytes,220,opt,name=x220",
}
var E_X221 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 221,
Name: "testdata.x221",
Tag: "bytes,221,opt,name=x221",
}
var E_X222 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 222,
Name: "testdata.x222",
Tag: "bytes,222,opt,name=x222",
}
var E_X223 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 223,
Name: "testdata.x223",
Tag: "bytes,223,opt,name=x223",
}
var E_X224 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 224,
Name: "testdata.x224",
Tag: "bytes,224,opt,name=x224",
}
var E_X225 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 225,
Name: "testdata.x225",
Tag: "bytes,225,opt,name=x225",
}
var E_X226 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 226,
Name: "testdata.x226",
Tag: "bytes,226,opt,name=x226",
}
var E_X227 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 227,
Name: "testdata.x227",
Tag: "bytes,227,opt,name=x227",
}
var E_X228 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 228,
Name: "testdata.x228",
Tag: "bytes,228,opt,name=x228",
}
var E_X229 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 229,
Name: "testdata.x229",
Tag: "bytes,229,opt,name=x229",
}
var E_X230 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 230,
Name: "testdata.x230",
Tag: "bytes,230,opt,name=x230",
}
var E_X231 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 231,
Name: "testdata.x231",
Tag: "bytes,231,opt,name=x231",
}
var E_X232 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 232,
Name: "testdata.x232",
Tag: "bytes,232,opt,name=x232",
}
var E_X233 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 233,
Name: "testdata.x233",
Tag: "bytes,233,opt,name=x233",
}
var E_X234 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 234,
Name: "testdata.x234",
Tag: "bytes,234,opt,name=x234",
}
var E_X235 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 235,
Name: "testdata.x235",
Tag: "bytes,235,opt,name=x235",
}
var E_X236 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 236,
Name: "testdata.x236",
Tag: "bytes,236,opt,name=x236",
}
var E_X237 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 237,
Name: "testdata.x237",
Tag: "bytes,237,opt,name=x237",
}
var E_X238 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 238,
Name: "testdata.x238",
Tag: "bytes,238,opt,name=x238",
}
var E_X239 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 239,
Name: "testdata.x239",
Tag: "bytes,239,opt,name=x239",
}
var E_X240 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 240,
Name: "testdata.x240",
Tag: "bytes,240,opt,name=x240",
}
var E_X241 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 241,
Name: "testdata.x241",
Tag: "bytes,241,opt,name=x241",
}
var E_X242 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 242,
Name: "testdata.x242",
Tag: "bytes,242,opt,name=x242",
}
var E_X243 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 243,
Name: "testdata.x243",
Tag: "bytes,243,opt,name=x243",
}
var E_X244 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 244,
Name: "testdata.x244",
Tag: "bytes,244,opt,name=x244",
}
var E_X245 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 245,
Name: "testdata.x245",
Tag: "bytes,245,opt,name=x245",
}
var E_X246 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 246,
Name: "testdata.x246",
Tag: "bytes,246,opt,name=x246",
}
var E_X247 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 247,
Name: "testdata.x247",
Tag: "bytes,247,opt,name=x247",
}
var E_X248 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 248,
Name: "testdata.x248",
Tag: "bytes,248,opt,name=x248",
}
var E_X249 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 249,
Name: "testdata.x249",
Tag: "bytes,249,opt,name=x249",
}
var E_X250 = &proto.ExtensionDesc{
ExtendedType: (*MyMessageSet)(nil),
ExtensionType: (*Empty)(nil),
Field: 250,
Name: "testdata.x250",
Tag: "bytes,250,opt,name=x250",
}
func init() {
proto.RegisterEnum("testdata.FOO", FOO_name, FOO_value)
proto.RegisterEnum("testdata.GoTest_KIND", GoTest_KIND_name, GoTest_KIND_value)
proto.RegisterEnum("testdata.MyMessage_Color", MyMessage_Color_name, MyMessage_Color_value)
proto.RegisterEnum("testdata.DefaultsMessage_DefaultsEnum", DefaultsMessage_DefaultsEnum_name, DefaultsMessage_DefaultsEnum_value)
proto.RegisterEnum("testdata.Defaults_Color", Defaults_Color_name, Defaults_Color_value)
proto.RegisterEnum("testdata.RepeatedEnum_Color", RepeatedEnum_Color_name, RepeatedEnum_Color_value)
proto.RegisterExtension(E_Ext_More)
proto.RegisterExtension(E_Ext_Text)
proto.RegisterExtension(E_Ext_Number)
proto.RegisterExtension(E_Greeting)
proto.RegisterExtension(E_NoDefaultDouble)
proto.RegisterExtension(E_NoDefaultFloat)
proto.RegisterExtension(E_NoDefaultInt32)
proto.RegisterExtension(E_NoDefaultInt64)
proto.RegisterExtension(E_NoDefaultUint32)
proto.RegisterExtension(E_NoDefaultUint64)
proto.RegisterExtension(E_NoDefaultSint32)
proto.RegisterExtension(E_NoDefaultSint64)
proto.RegisterExtension(E_NoDefaultFixed32)
proto.RegisterExtension(E_NoDefaultFixed64)
proto.RegisterExtension(E_NoDefaultSfixed32)
proto.RegisterExtension(E_NoDefaultSfixed64)
proto.RegisterExtension(E_NoDefaultBool)
proto.RegisterExtension(E_NoDefaultString)
proto.RegisterExtension(E_NoDefaultBytes)
proto.RegisterExtension(E_NoDefaultEnum)
proto.RegisterExtension(E_DefaultDouble)
proto.RegisterExtension(E_DefaultFloat)
proto.RegisterExtension(E_DefaultInt32)
proto.RegisterExtension(E_DefaultInt64)
proto.RegisterExtension(E_DefaultUint32)
proto.RegisterExtension(E_DefaultUint64)
proto.RegisterExtension(E_DefaultSint32)
proto.RegisterExtension(E_DefaultSint64)
proto.RegisterExtension(E_DefaultFixed32)
proto.RegisterExtension(E_DefaultFixed64)
proto.RegisterExtension(E_DefaultSfixed32)
proto.RegisterExtension(E_DefaultSfixed64)
proto.RegisterExtension(E_DefaultBool)
proto.RegisterExtension(E_DefaultString)
proto.RegisterExtension(E_DefaultBytes)
proto.RegisterExtension(E_DefaultEnum)
proto.RegisterExtension(E_X201)
proto.RegisterExtension(E_X202)
proto.RegisterExtension(E_X203)
proto.RegisterExtension(E_X204)
proto.RegisterExtension(E_X205)
proto.RegisterExtension(E_X206)
proto.RegisterExtension(E_X207)
proto.RegisterExtension(E_X208)
proto.RegisterExtension(E_X209)
proto.RegisterExtension(E_X210)
proto.RegisterExtension(E_X211)
proto.RegisterExtension(E_X212)
proto.RegisterExtension(E_X213)
proto.RegisterExtension(E_X214)
proto.RegisterExtension(E_X215)
proto.RegisterExtension(E_X216)
proto.RegisterExtension(E_X217)
proto.RegisterExtension(E_X218)
proto.RegisterExtension(E_X219)
proto.RegisterExtension(E_X220)
proto.RegisterExtension(E_X221)
proto.RegisterExtension(E_X222)
proto.RegisterExtension(E_X223)
proto.RegisterExtension(E_X224)
proto.RegisterExtension(E_X225)
proto.RegisterExtension(E_X226)
proto.RegisterExtension(E_X227)
proto.RegisterExtension(E_X228)
proto.RegisterExtension(E_X229)
proto.RegisterExtension(E_X230)
proto.RegisterExtension(E_X231)
proto.RegisterExtension(E_X232)
proto.RegisterExtension(E_X233)
proto.RegisterExtension(E_X234)
proto.RegisterExtension(E_X235)
proto.RegisterExtension(E_X236)
proto.RegisterExtension(E_X237)
proto.RegisterExtension(E_X238)
proto.RegisterExtension(E_X239)
proto.RegisterExtension(E_X240)
proto.RegisterExtension(E_X241)
proto.RegisterExtension(E_X242)
proto.RegisterExtension(E_X243)
proto.RegisterExtension(E_X244)
proto.RegisterExtension(E_X245)
proto.RegisterExtension(E_X246)
proto.RegisterExtension(E_X247)
proto.RegisterExtension(E_X248)
proto.RegisterExtension(E_X249)
proto.RegisterExtension(E_X250)
}
// Code generated by protoc-gen-gogo.
// source: test.proto
// DO NOT EDIT!
package testdata
import proto "github.com/gogo/protobuf/proto"
import json "encoding/json"
import math "math"
import ()
// Reference proto, json, and math imports to suppress error if they are not otherwise used.
var _ = proto.Marshal
var _ = &json.SyntaxError{}
var _ = math.Inf
type FOO int32
const (
FOO_FOO1 FOO = 1
)
var FOO_name = map[int32]string{
1: "FOO1",
}
var FOO_value = map[string]int32{
"FOO1": 1,
}
func (x FOO) Enum() *FOO {
p := new(FOO)
*p = x
return p
}
func (x FOO) String() string {
return proto.EnumName(FOO_name, int32(x))
}
func (x FOO) MarshalJSON() ([]byte, error) {
return json.Marshal(x.String())
}
func (x *FOO) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(FOO_value, data, "FOO")
if err != nil {
return err
}
*x = FOO(value)
return nil
}
type GoTest_KIND int32
const (
GoTest_VOID GoTest_KIND = 0
GoTest_BOOL GoTest_KIND = 1
GoTest_BYTES GoTest_KIND = 2
GoTest_FINGERPRINT GoTest_KIND = 3
GoTest_FLOAT GoTest_KIND = 4
GoTest_INT GoTest_KIND = 5
GoTest_STRING GoTest_KIND = 6
GoTest_TIME GoTest_KIND = 7
GoTest_TUPLE GoTest_KIND = 8
GoTest_ARRAY GoTest_KIND = 9
GoTest_MAP GoTest_KIND = 10
GoTest_TABLE GoTest_KIND = 11
GoTest_FUNCTION GoTest_KIND = 12
)
var GoTest_KIND_name = map[int32]string{
0: "VOID",
1: "BOOL",
2: "BYTES",
3: "FINGERPRINT",
4: "FLOAT",
5: "INT",
6: "STRING",
7: "TIME",
8: "TUPLE",
9: "ARRAY",
10: "MAP",
11: "TABLE",
12: "FUNCTION",
}
var GoTest_KIND_value = map[string]int32{
"VOID": 0,
"BOOL": 1,
"BYTES": 2,
"FINGERPRINT": 3,
"FLOAT": 4,
"INT": 5,
"STRING": 6,
"TIME": 7,
"TUPLE": 8,
"ARRAY": 9,
"MAP": 10,
"TABLE": 11,
"FUNCTION": 12,
}
func (x GoTest_KIND) Enum() *GoTest_KIND {
p := new(GoTest_KIND)
*p = x
return p
}
func (x GoTest_KIND) String() string {
return proto.EnumName(GoTest_KIND_name, int32(x))
}
func (x GoTest_KIND) MarshalJSON() ([]byte, error) {
return json.Marshal(x.String())
}
func (x *GoTest_KIND) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(GoTest_KIND_value, data, "GoTest_KIND")
if err != nil {
return err
}
*x = GoTest_KIND(value)
return nil
}
type MyMessage_Color int32
const (
MyMessage_RED MyMessage_Color = 0
MyMessage_GREEN MyMessage_Color = 1
MyMessage_BLUE MyMessage_Color = 2
)
var MyMessage_Color_name = map[int32]string{
0: "RED",
1: "GREEN",
2: "BLUE",
}
var MyMessage_Color_value = map[string]int32{
"RED": 0,
"GREEN": 1,
"BLUE": 2,
}
func (x MyMessage_Color) Enum() *MyMessage_Color {
p := new(MyMessage_Color)
*p = x
return p
}
func (x MyMessage_Color) String() string {
return proto.EnumName(MyMessage_Color_name, int32(x))
}
func (x MyMessage_Color) MarshalJSON() ([]byte, error) {
return json.Marshal(x.String())
}
func (x *MyMessage_Color) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(MyMessage_Color_value, data, "MyMessage_Color")
if err != nil {
return err
}
*x = MyMessage_Color(value)
return nil
}
type Defaults_Color int32
const (
Defaults_RED Defaults_Color = 0
Defaults_GREEN Defaults_Color = 1
Defaults_BLUE Defaults_Color = 2
)
var Defaults_Color_name = map[int32]string{
0: "RED",
1: "GREEN",
2: "BLUE",
}
var Defaults_Color_value = map[string]int32{
"RED": 0,
"GREEN": 1,
"BLUE": 2,
}
func (x Defaults_Color) Enum() *Defaults_Color {
p := new(Defaults_Color)
*p = x
return p
}
func (x Defaults_Color) String() string {
return proto.EnumName(Defaults_Color_name, int32(x))
}
func (x Defaults_Color) MarshalJSON() ([]byte, error) {
return json.Marshal(x.String())
}
func (x *Defaults_Color) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(Defaults_Color_value, data, "Defaults_Color")
if err != nil {
return err
}
*x = Defaults_Color(value)
return nil
}
type RepeatedEnum_Color int32
const (
RepeatedEnum_RED RepeatedEnum_Color = 1
)
var RepeatedEnum_Color_name = map[int32]string{
1: "RED",
}
var RepeatedEnum_Color_value = map[string]int32{
"RED": 1,
}
func (x RepeatedEnum_Color) Enum() *RepeatedEnum_Color {
p := new(RepeatedEnum_Color)
*p = x
return p
}
func (x RepeatedEnum_Color) String() string {
return proto.EnumName(RepeatedEnum_Color_name, int32(x))
}
func (x RepeatedEnum_Color) MarshalJSON() ([]byte, error) {
return json.Marshal(x.String())
}
func (x *RepeatedEnum_Color) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(RepeatedEnum_Color_value, data, "RepeatedEnum_Color")
if err != nil {
return err
}
*x = RepeatedEnum_Color(value)
return nil
}
type GoEnum struct {
Foo *FOO `protobuf:"varint,1,req,name=foo,enum=testdata.FOO" json:"foo,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoEnum) Reset() { *m = GoEnum{} }
func (m *GoEnum) String() string { return proto.CompactTextString(m) }
func (*GoEnum) ProtoMessage() {}
func (m *GoEnum) GetFoo() FOO {
if m != nil && m.Foo != nil {
return *m.Foo
}
return 0
}
type GoTestField struct {
Label *string `protobuf:"bytes,1,req" json:"Label,omitempty"`
Type *string `protobuf:"bytes,2,req" json:"Type,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTestField) Reset() { *m = GoTestField{} }
func (m *GoTestField) String() string { return proto.CompactTextString(m) }
func (*GoTestField) ProtoMessage() {}
func (m *GoTestField) GetLabel() string {
if m != nil && m.Label != nil {
return *m.Label
}
return ""
}
func (m *GoTestField) GetType() string {
if m != nil && m.Type != nil {
return *m.Type
}
return ""
}
type GoTest struct {
Kind *GoTest_KIND `protobuf:"varint,1,req,enum=testdata.GoTest_KIND" json:"Kind,omitempty"`
Table *string `protobuf:"bytes,2,opt" json:"Table,omitempty"`
Param *int32 `protobuf:"varint,3,opt" json:"Param,omitempty"`
RequiredField *GoTestField `protobuf:"bytes,4,req" json:"RequiredField,omitempty"`
RepeatedField []*GoTestField `protobuf:"bytes,5,rep" json:"RepeatedField,omitempty"`
OptionalField *GoTestField `protobuf:"bytes,6,opt" json:"OptionalField,omitempty"`
F_BoolRequired *bool `protobuf:"varint,10,req,name=F_Bool_required" json:"F_Bool_required,omitempty"`
F_Int32Required *int32 `protobuf:"varint,11,req,name=F_Int32_required" json:"F_Int32_required,omitempty"`
F_Int64Required *int64 `protobuf:"varint,12,req,name=F_Int64_required" json:"F_Int64_required,omitempty"`
F_Fixed32Required *uint32 `protobuf:"fixed32,13,req,name=F_Fixed32_required" json:"F_Fixed32_required,omitempty"`
F_Fixed64Required *uint64 `protobuf:"fixed64,14,req,name=F_Fixed64_required" json:"F_Fixed64_required,omitempty"`
F_Uint32Required *uint32 `protobuf:"varint,15,req,name=F_Uint32_required" json:"F_Uint32_required,omitempty"`
F_Uint64Required *uint64 `protobuf:"varint,16,req,name=F_Uint64_required" json:"F_Uint64_required,omitempty"`
F_FloatRequired *float32 `protobuf:"fixed32,17,req,name=F_Float_required" json:"F_Float_required,omitempty"`
F_DoubleRequired *float64 `protobuf:"fixed64,18,req,name=F_Double_required" json:"F_Double_required,omitempty"`
F_StringRequired *string `protobuf:"bytes,19,req,name=F_String_required" json:"F_String_required,omitempty"`
F_BytesRequired []byte `protobuf:"bytes,101,req,name=F_Bytes_required" json:"F_Bytes_required,omitempty"`
F_Sint32Required *int32 `protobuf:"zigzag32,102,req,name=F_Sint32_required" json:"F_Sint32_required,omitempty"`
F_Sint64Required *int64 `protobuf:"zigzag64,103,req,name=F_Sint64_required" json:"F_Sint64_required,omitempty"`
F_BoolRepeated []bool `protobuf:"varint,20,rep,name=F_Bool_repeated" json:"F_Bool_repeated,omitempty"`
F_Int32Repeated []int32 `protobuf:"varint,21,rep,name=F_Int32_repeated" json:"F_Int32_repeated,omitempty"`
F_Int64Repeated []int64 `protobuf:"varint,22,rep,name=F_Int64_repeated" json:"F_Int64_repeated,omitempty"`
F_Fixed32Repeated []uint32 `protobuf:"fixed32,23,rep,name=F_Fixed32_repeated" json:"F_Fixed32_repeated,omitempty"`
F_Fixed64Repeated []uint64 `protobuf:"fixed64,24,rep,name=F_Fixed64_repeated" json:"F_Fixed64_repeated,omitempty"`
F_Uint32Repeated []uint32 `protobuf:"varint,25,rep,name=F_Uint32_repeated" json:"F_Uint32_repeated,omitempty"`
F_Uint64Repeated []uint64 `protobuf:"varint,26,rep,name=F_Uint64_repeated" json:"F_Uint64_repeated,omitempty"`
F_FloatRepeated []float32 `protobuf:"fixed32,27,rep,name=F_Float_repeated" json:"F_Float_repeated,omitempty"`
F_DoubleRepeated []float64 `protobuf:"fixed64,28,rep,name=F_Double_repeated" json:"F_Double_repeated,omitempty"`
F_StringRepeated []string `protobuf:"bytes,29,rep,name=F_String_repeated" json:"F_String_repeated,omitempty"`
F_BytesRepeated [][]byte `protobuf:"bytes,201,rep,name=F_Bytes_repeated" json:"F_Bytes_repeated,omitempty"`
F_Sint32Repeated []int32 `protobuf:"zigzag32,202,rep,name=F_Sint32_repeated" json:"F_Sint32_repeated,omitempty"`
F_Sint64Repeated []int64 `protobuf:"zigzag64,203,rep,name=F_Sint64_repeated" json:"F_Sint64_repeated,omitempty"`
F_BoolOptional *bool `protobuf:"varint,30,opt,name=F_Bool_optional" json:"F_Bool_optional,omitempty"`
F_Int32Optional *int32 `protobuf:"varint,31,opt,name=F_Int32_optional" json:"F_Int32_optional,omitempty"`
F_Int64Optional *int64 `protobuf:"varint,32,opt,name=F_Int64_optional" json:"F_Int64_optional,omitempty"`
F_Fixed32Optional *uint32 `protobuf:"fixed32,33,opt,name=F_Fixed32_optional" json:"F_Fixed32_optional,omitempty"`
F_Fixed64Optional *uint64 `protobuf:"fixed64,34,opt,name=F_Fixed64_optional" json:"F_Fixed64_optional,omitempty"`
F_Uint32Optional *uint32 `protobuf:"varint,35,opt,name=F_Uint32_optional" json:"F_Uint32_optional,omitempty"`
F_Uint64Optional *uint64 `protobuf:"varint,36,opt,name=F_Uint64_optional" json:"F_Uint64_optional,omitempty"`
F_FloatOptional *float32 `protobuf:"fixed32,37,opt,name=F_Float_optional" json:"F_Float_optional,omitempty"`
F_DoubleOptional *float64 `protobuf:"fixed64,38,opt,name=F_Double_optional" json:"F_Double_optional,omitempty"`
F_StringOptional *string `protobuf:"bytes,39,opt,name=F_String_optional" json:"F_String_optional,omitempty"`
F_BytesOptional []byte `protobuf:"bytes,301,opt,name=F_Bytes_optional" json:"F_Bytes_optional,omitempty"`
F_Sint32Optional *int32 `protobuf:"zigzag32,302,opt,name=F_Sint32_optional" json:"F_Sint32_optional,omitempty"`
F_Sint64Optional *int64 `protobuf:"zigzag64,303,opt,name=F_Sint64_optional" json:"F_Sint64_optional,omitempty"`
F_BoolDefaulted *bool `protobuf:"varint,40,opt,name=F_Bool_defaulted,def=1" json:"F_Bool_defaulted,omitempty"`
F_Int32Defaulted *int32 `protobuf:"varint,41,opt,name=F_Int32_defaulted,def=32" json:"F_Int32_defaulted,omitempty"`
F_Int64Defaulted *int64 `protobuf:"varint,42,opt,name=F_Int64_defaulted,def=64" json:"F_Int64_defaulted,omitempty"`
F_Fixed32Defaulted *uint32 `protobuf:"fixed32,43,opt,name=F_Fixed32_defaulted,def=320" json:"F_Fixed32_defaulted,omitempty"`
F_Fixed64Defaulted *uint64 `protobuf:"fixed64,44,opt,name=F_Fixed64_defaulted,def=640" json:"F_Fixed64_defaulted,omitempty"`
F_Uint32Defaulted *uint32 `protobuf:"varint,45,opt,name=F_Uint32_defaulted,def=3200" json:"F_Uint32_defaulted,omitempty"`
F_Uint64Defaulted *uint64 `protobuf:"varint,46,opt,name=F_Uint64_defaulted,def=6400" json:"F_Uint64_defaulted,omitempty"`
F_FloatDefaulted *float32 `protobuf:"fixed32,47,opt,name=F_Float_defaulted,def=314159" json:"F_Float_defaulted,omitempty"`
F_DoubleDefaulted *float64 `protobuf:"fixed64,48,opt,name=F_Double_defaulted,def=271828" json:"F_Double_defaulted,omitempty"`
F_StringDefaulted *string `protobuf:"bytes,49,opt,name=F_String_defaulted,def=hello, \"world!\"\n" json:"F_String_defaulted,omitempty"`
F_BytesDefaulted []byte `protobuf:"bytes,401,opt,name=F_Bytes_defaulted,def=Bignose" json:"F_Bytes_defaulted,omitempty"`
F_Sint32Defaulted *int32 `protobuf:"zigzag32,402,opt,name=F_Sint32_defaulted,def=-32" json:"F_Sint32_defaulted,omitempty"`
F_Sint64Defaulted *int64 `protobuf:"zigzag64,403,opt,name=F_Sint64_defaulted,def=-64" json:"F_Sint64_defaulted,omitempty"`
F_BoolRepeatedPacked []bool `protobuf:"varint,50,rep,packed,name=F_Bool_repeated_packed" json:"F_Bool_repeated_packed,omitempty"`
F_Int32RepeatedPacked []int32 `protobuf:"varint,51,rep,packed,name=F_Int32_repeated_packed" json:"F_Int32_repeated_packed,omitempty"`
F_Int64RepeatedPacked []int64 `protobuf:"varint,52,rep,packed,name=F_Int64_repeated_packed" json:"F_Int64_repeated_packed,omitempty"`
F_Fixed32RepeatedPacked []uint32 `protobuf:"fixed32,53,rep,packed,name=F_Fixed32_repeated_packed" json:"F_Fixed32_repeated_packed,omitempty"`
F_Fixed64RepeatedPacked []uint64 `protobuf:"fixed64,54,rep,packed,name=F_Fixed64_repeated_packed" json:"F_Fixed64_repeated_packed,omitempty"`
F_Uint32RepeatedPacked []uint32 `protobuf:"varint,55,rep,packed,name=F_Uint32_repeated_packed" json:"F_Uint32_repeated_packed,omitempty"`
F_Uint64RepeatedPacked []uint64 `protobuf:"varint,56,rep,packed,name=F_Uint64_repeated_packed" json:"F_Uint64_repeated_packed,omitempty"`
F_FloatRepeatedPacked []float32 `protobuf:"fixed32,57,rep,packed,name=F_Float_repeated_packed" json:"F_Float_repeated_packed,omitempty"`
F_DoubleRepeatedPacked []float64 `protobuf:"fixed64,58,rep,packed,name=F_Double_repeated_packed" json:"F_Double_repeated_packed,omitempty"`
F_Sint32RepeatedPacked []int32 `protobuf:"zigzag32,502,rep,packed,name=F_Sint32_repeated_packed" json:"F_Sint32_repeated_packed,omitempty"`
F_Sint64RepeatedPacked []int64 `protobuf:"zigzag64,503,rep,packed,name=F_Sint64_repeated_packed" json:"F_Sint64_repeated_packed,omitempty"`
Requiredgroup *GoTest_RequiredGroup `protobuf:"group,70,req,name=RequiredGroup" json:"requiredgroup,omitempty"`
Repeatedgroup []*GoTest_RepeatedGroup `protobuf:"group,80,rep,name=RepeatedGroup" json:"repeatedgroup,omitempty"`
Optionalgroup *GoTest_OptionalGroup `protobuf:"group,90,opt,name=OptionalGroup" json:"optionalgroup,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTest) Reset() { *m = GoTest{} }
func (m *GoTest) String() string { return proto.CompactTextString(m) }
func (*GoTest) ProtoMessage() {}
const Default_GoTest_F_BoolDefaulted bool = true
const Default_GoTest_F_Int32Defaulted int32 = 32
const Default_GoTest_F_Int64Defaulted int64 = 64
const Default_GoTest_F_Fixed32Defaulted uint32 = 320
const Default_GoTest_F_Fixed64Defaulted uint64 = 640
const Default_GoTest_F_Uint32Defaulted uint32 = 3200
const Default_GoTest_F_Uint64Defaulted uint64 = 6400
const Default_GoTest_F_FloatDefaulted float32 = 314159
const Default_GoTest_F_DoubleDefaulted float64 = 271828
const Default_GoTest_F_StringDefaulted string = "hello, \"world!\"\n"
var Default_GoTest_F_BytesDefaulted []byte = []byte("Bignose")
const Default_GoTest_F_Sint32Defaulted int32 = -32
const Default_GoTest_F_Sint64Defaulted int64 = -64
func (m *GoTest) GetKind() GoTest_KIND {
if m != nil && m.Kind != nil {
return *m.Kind
}
return 0
}
func (m *GoTest) GetTable() string {
if m != nil && m.Table != nil {
return *m.Table
}
return ""
}
func (m *GoTest) GetParam() int32 {
if m != nil && m.Param != nil {
return *m.Param
}
return 0
}
func (m *GoTest) GetRequiredField() *GoTestField {
if m != nil {
return m.RequiredField
}
return nil
}
func (m *GoTest) GetRepeatedField() []*GoTestField {
if m != nil {
return m.RepeatedField
}
return nil
}
func (m *GoTest) GetOptionalField() *GoTestField {
if m != nil {
return m.OptionalField
}
return nil
}
func (m *GoTest) GetF_BoolRequired() bool {
if m != nil && m.F_BoolRequired != nil {
return *m.F_BoolRequired
}
return false
}
func (m *GoTest) GetF_Int32Required() int32 {
if m != nil && m.F_Int32Required != nil {
return *m.F_Int32Required
}
return 0
}
func (m *GoTest) GetF_Int64Required() int64 {
if m != nil && m.F_Int64Required != nil {
return *m.F_Int64Required
}
return 0
}
func (m *GoTest) GetF_Fixed32Required() uint32 {
if m != nil && m.F_Fixed32Required != nil {
return *m.F_Fixed32Required
}
return 0
}
func (m *GoTest) GetF_Fixed64Required() uint64 {
if m != nil && m.F_Fixed64Required != nil {
return *m.F_Fixed64Required
}
return 0
}
func (m *GoTest) GetF_Uint32Required() uint32 {
if m != nil && m.F_Uint32Required != nil {
return *m.F_Uint32Required
}
return 0
}
func (m *GoTest) GetF_Uint64Required() uint64 {
if m != nil && m.F_Uint64Required != nil {
return *m.F_Uint64Required
}
return 0
}
func (m *GoTest) GetF_FloatRequired() float32 {
if m != nil && m.F_FloatRequired != nil {
return *m.F_FloatRequired
}
return 0
}
func (m *GoTest) GetF_DoubleRequired() float64 {
if m != nil && m.F_DoubleRequired != nil {
return *m.F_DoubleRequired
}
return 0
}
func (m *GoTest) GetF_StringRequired() string {
if m != nil && m.F_StringRequired != nil {
return *m.F_StringRequired
}
return ""
}
func (m *GoTest) GetF_BytesRequired() []byte {
if m != nil {
return m.F_BytesRequired
}
return nil
}
func (m *GoTest) GetF_Sint32Required() int32 {
if m != nil && m.F_Sint32Required != nil {
return *m.F_Sint32Required
}
return 0
}
func (m *GoTest) GetF_Sint64Required() int64 {
if m != nil && m.F_Sint64Required != nil {
return *m.F_Sint64Required
}
return 0
}
func (m *GoTest) GetF_BoolRepeated() []bool {
if m != nil {
return m.F_BoolRepeated
}
return nil
}
func (m *GoTest) GetF_Int32Repeated() []int32 {
if m != nil {
return m.F_Int32Repeated
}
return nil
}
func (m *GoTest) GetF_Int64Repeated() []int64 {
if m != nil {
return m.F_Int64Repeated
}
return nil
}
func (m *GoTest) GetF_Fixed32Repeated() []uint32 {
if m != nil {
return m.F_Fixed32Repeated
}
return nil
}
func (m *GoTest) GetF_Fixed64Repeated() []uint64 {
if m != nil {
return m.F_Fixed64Repeated
}
return nil
}
func (m *GoTest) GetF_Uint32Repeated() []uint32 {
if m != nil {
return m.F_Uint32Repeated
}
return nil
}
func (m *GoTest) GetF_Uint64Repeated() []uint64 {
if m != nil {
return m.F_Uint64Repeated
}
return nil
}
func (m *GoTest) GetF_FloatRepeated() []float32 {
if m != nil {
return m.F_FloatRepeated
}
return nil
}
func (m *GoTest) GetF_DoubleRepeated() []float64 {
if m != nil {
return m.F_DoubleRepeated
}
return nil
}
func (m *GoTest) GetF_StringRepeated() []string {
if m != nil {
return m.F_StringRepeated
}
return nil
}
func (m *GoTest) GetF_BytesRepeated() [][]byte {
if m != nil {
return m.F_BytesRepeated
}
return nil
}
func (m *GoTest) GetF_Sint32Repeated() []int32 {
if m != nil {
return m.F_Sint32Repeated
}
return nil
}
func (m *GoTest) GetF_Sint64Repeated() []int64 {
if m != nil {
return m.F_Sint64Repeated
}
return nil
}
func (m *GoTest) GetF_BoolOptional() bool {
if m != nil && m.F_BoolOptional != nil {
return *m.F_BoolOptional
}
return false
}
func (m *GoTest) GetF_Int32Optional() int32 {
if m != nil && m.F_Int32Optional != nil {
return *m.F_Int32Optional
}
return 0
}
func (m *GoTest) GetF_Int64Optional() int64 {
if m != nil && m.F_Int64Optional != nil {
return *m.F_Int64Optional
}
return 0
}
func (m *GoTest) GetF_Fixed32Optional() uint32 {
if m != nil && m.F_Fixed32Optional != nil {
return *m.F_Fixed32Optional
}
return 0
}
func (m *GoTest) GetF_Fixed64Optional() uint64 {
if m != nil && m.F_Fixed64Optional != nil {
return *m.F_Fixed64Optional
}
return 0
}
func (m *GoTest) GetF_Uint32Optional() uint32 {
if m != nil && m.F_Uint32Optional != nil {
return *m.F_Uint32Optional
}
return 0
}
func (m *GoTest) GetF_Uint64Optional() uint64 {
if m != nil && m.F_Uint64Optional != nil {
return *m.F_Uint64Optional
}
return 0
}
func (m *GoTest) GetF_FloatOptional() float32 {
if m != nil && m.F_FloatOptional != nil {
return *m.F_FloatOptional
}
return 0
}
func (m *GoTest) GetF_DoubleOptional() float64 {
if m != nil && m.F_DoubleOptional != nil {
return *m.F_DoubleOptional
}
return 0
}
func (m *GoTest) GetF_StringOptional() string {
if m != nil && m.F_StringOptional != nil {
return *m.F_StringOptional
}
return ""
}
func (m *GoTest) GetF_BytesOptional() []byte {
if m != nil {
return m.F_BytesOptional
}
return nil
}
func (m *GoTest) GetF_Sint32Optional() int32 {
if m != nil && m.F_Sint32Optional != nil {
return *m.F_Sint32Optional
}
return 0
}
func (m *GoTest) GetF_Sint64Optional() int64 {
if m != nil && m.F_Sint64Optional != nil {
return *m.F_Sint64Optional
}
return 0
}
func (m *GoTest) GetF_BoolDefaulted() bool {
if m != nil && m.F_BoolDefaulted != nil {
return *m.F_BoolDefaulted
}
return Default_GoTest_F_BoolDefaulted
}
func (m *GoTest) GetF_Int32Defaulted() int32 {
if m != nil && m.F_Int32Defaulted != nil {
return *m.F_Int32Defaulted
}
return Default_GoTest_F_Int32Defaulted
}
func (m *GoTest) GetF_Int64Defaulted() int64 {
if m != nil && m.F_Int64Defaulted != nil {
return *m.F_Int64Defaulted
}
return Default_GoTest_F_Int64Defaulted
}
func (m *GoTest) GetF_Fixed32Defaulted() uint32 {
if m != nil && m.F_Fixed32Defaulted != nil {
return *m.F_Fixed32Defaulted
}
return Default_GoTest_F_Fixed32Defaulted
}
func (m *GoTest) GetF_Fixed64Defaulted() uint64 {
if m != nil && m.F_Fixed64Defaulted != nil {
return *m.F_Fixed64Defaulted
}
return Default_GoTest_F_Fixed64Defaulted
}
func (m *GoTest) GetF_Uint32Defaulted() uint32 {
if m != nil && m.F_Uint32Defaulted != nil {
return *m.F_Uint32Defaulted
}
return Default_GoTest_F_Uint32Defaulted
}
func (m *GoTest) GetF_Uint64Defaulted() uint64 {
if m != nil && m.F_Uint64Defaulted != nil {
return *m.F_Uint64Defaulted
}
return Default_GoTest_F_Uint64Defaulted
}
func (m *GoTest) GetF_FloatDefaulted() float32 {
if m != nil && m.F_FloatDefaulted != nil {
return *m.F_FloatDefaulted
}
return Default_GoTest_F_FloatDefaulted
}
func (m *GoTest) GetF_DoubleDefaulted() float64 {
if m != nil && m.F_DoubleDefaulted != nil {
return *m.F_DoubleDefaulted
}
return Default_GoTest_F_DoubleDefaulted
}
func (m *GoTest) GetF_StringDefaulted() string {
if m != nil && m.F_StringDefaulted != nil {
return *m.F_StringDefaulted
}
return Default_GoTest_F_StringDefaulted
}
func (m *GoTest) GetF_BytesDefaulted() []byte {
if m != nil && m.F_BytesDefaulted != nil {
return m.F_BytesDefaulted
}
return append([]byte(nil), Default_GoTest_F_BytesDefaulted...)
}
func (m *GoTest) GetF_Sint32Defaulted() int32 {
if m != nil && m.F_Sint32Defaulted != nil {
return *m.F_Sint32Defaulted
}
return Default_GoTest_F_Sint32Defaulted
}
func (m *GoTest) GetF_Sint64Defaulted() int64 {
if m != nil && m.F_Sint64Defaulted != nil {
return *m.F_Sint64Defaulted
}
return Default_GoTest_F_Sint64Defaulted
}
func (m *GoTest) GetF_BoolRepeatedPacked() []bool {
if m != nil {
return m.F_BoolRepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Int32RepeatedPacked() []int32 {
if m != nil {
return m.F_Int32RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Int64RepeatedPacked() []int64 {
if m != nil {
return m.F_Int64RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Fixed32RepeatedPacked() []uint32 {
if m != nil {
return m.F_Fixed32RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Fixed64RepeatedPacked() []uint64 {
if m != nil {
return m.F_Fixed64RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Uint32RepeatedPacked() []uint32 {
if m != nil {
return m.F_Uint32RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Uint64RepeatedPacked() []uint64 {
if m != nil {
return m.F_Uint64RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_FloatRepeatedPacked() []float32 {
if m != nil {
return m.F_FloatRepeatedPacked
}
return nil
}
func (m *GoTest) GetF_DoubleRepeatedPacked() []float64 {
if m != nil {
return m.F_DoubleRepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Sint32RepeatedPacked() []int32 {
if m != nil {
return m.F_Sint32RepeatedPacked
}
return nil
}
func (m *GoTest) GetF_Sint64RepeatedPacked() []int64 {
if m != nil {
return m.F_Sint64RepeatedPacked
}
return nil
}
func (m *GoTest) GetRequiredgroup() *GoTest_RequiredGroup {
if m != nil {
return m.Requiredgroup
}
return nil
}
func (m *GoTest) GetRepeatedgroup() []*GoTest_RepeatedGroup {
if m != nil {
return m.Repeatedgroup
}
return nil
}
func (m *GoTest) GetOptionalgroup() *GoTest_OptionalGroup {
if m != nil {
return m.Optionalgroup
}
return nil
}
type GoTest_RequiredGroup struct {
RequiredField *string `protobuf:"bytes,71,req" json:"RequiredField,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTest_RequiredGroup) Reset() { *m = GoTest_RequiredGroup{} }
func (m *GoTest_RequiredGroup) GetRequiredField() string {
if m != nil && m.RequiredField != nil {
return *m.RequiredField
}
return ""
}
type GoTest_RepeatedGroup struct {
RequiredField *string `protobuf:"bytes,81,req" json:"RequiredField,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTest_RepeatedGroup) Reset() { *m = GoTest_RepeatedGroup{} }
func (m *GoTest_RepeatedGroup) GetRequiredField() string {
if m != nil && m.RequiredField != nil {
return *m.RequiredField
}
return ""
}
type GoTest_OptionalGroup struct {
RequiredField *string `protobuf:"bytes,91,req" json:"RequiredField,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoTest_OptionalGroup) Reset() { *m = GoTest_OptionalGroup{} }
func (m *GoTest_OptionalGroup) GetRequiredField() string {
if m != nil && m.RequiredField != nil {
return *m.RequiredField
}
return ""
}
type GoSkipTest struct {
SkipInt32 *int32 `protobuf:"varint,11,req,name=skip_int32" json:"skip_int32,omitempty"`
SkipFixed32 *uint32 `protobuf:"fixed32,12,req,name=skip_fixed32" json:"skip_fixed32,omitempty"`
SkipFixed64 *uint64 `protobuf:"fixed64,13,req,name=skip_fixed64" json:"skip_fixed64,omitempty"`
SkipString *string `protobuf:"bytes,14,req,name=skip_string" json:"skip_string,omitempty"`
Skipgroup *GoSkipTest_SkipGroup `protobuf:"group,15,req,name=SkipGroup" json:"skipgroup,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoSkipTest) Reset() { *m = GoSkipTest{} }
func (m *GoSkipTest) String() string { return proto.CompactTextString(m) }
func (*GoSkipTest) ProtoMessage() {}
func (m *GoSkipTest) GetSkipInt32() int32 {
if m != nil && m.SkipInt32 != nil {
return *m.SkipInt32
}
return 0
}
func (m *GoSkipTest) GetSkipFixed32() uint32 {
if m != nil && m.SkipFixed32 != nil {
return *m.SkipFixed32
}
return 0
}
func (m *GoSkipTest) GetSkipFixed64() uint64 {
if m != nil && m.SkipFixed64 != nil {
return *m.SkipFixed64
}
return 0
}
func (m *GoSkipTest) GetSkipString() string {
if m != nil && m.SkipString != nil {
return *m.SkipString
}
return ""
}
func (m *GoSkipTest) GetSkipgroup() *GoSkipTest_SkipGroup {
if m != nil {
return m.Skipgroup
}
return nil
}
type GoSkipTest_SkipGroup struct {
GroupInt32 *int32 `protobuf:"varint,16,req,name=group_int32" json:"group_int32,omitempty"`
GroupString *string `protobuf:"bytes,17,req,name=group_string" json:"group_string,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GoSkipTest_SkipGroup) Reset() { *m = GoSkipTest_SkipGroup{} }
func (m *GoSkipTest_SkipGroup) GetGroupInt32() int32 {
if m != nil && m.GroupInt32 != nil {
return *m.GroupInt32
}
return 0
}
func (m *GoSkipTest_SkipGroup) GetGroupString() string {
if m != nil && m.GroupString != nil {
return *m.GroupString
}
return ""
}
type NonPackedTest struct {
A []int32 `protobuf:"varint,1,rep,name=a" json:"a,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *NonPackedTest) Reset() { *m = NonPackedTest{} }
func (m *NonPackedTest) String() string { return proto.CompactTextString(m) }
func (*NonPackedTest) ProtoMessage() {}
func (m *NonPackedTest) GetA() []int32 {
if m != nil {
return m.A
}
return nil
}
type PackedTest struct {
B []int32 `protobuf:"varint,1,rep,packed,name=b" json:"b,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *PackedTest) Reset() { *m = PackedTest{} }
func (m *PackedTest) String() string { return proto.CompactTextString(m) }
func (*PackedTest) ProtoMessage() {}
func (m *PackedTest) GetB() []int32 {
if m != nil {
return m.B
}
return nil
}
type MaxTag struct {
LastField *string `protobuf:"bytes,536870911,opt,name=last_field" json:"last_field,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MaxTag) Reset() { *m = MaxTag{} }
func (m *MaxTag) String() string { return proto.CompactTextString(m) }
func (*MaxTag) ProtoMessage() {}
func (m *MaxTag) GetLastField() string {
if m != nil && m.LastField != nil {
return *m.LastField
}
return ""
}
type OldMessage struct {
Nested *OldMessage_Nested `protobuf:"bytes,1,opt,name=nested" json:"nested,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *OldMessage) Reset() { *m = OldMessage{} }
func (m *OldMessage) String() string { return proto.CompactTextString(m) }
func (*OldMessage) ProtoMessage() {}
func (m *OldMessage) GetNested() *OldMessage_Nested {
if m != nil {
return m.Nested
}
return nil
}
type OldMessage_Nested struct {
Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *OldMessage_Nested) Reset() { *m = OldMessage_Nested{} }
func (m *OldMessage_Nested) String() string { return proto.CompactTextString(m) }
func (*OldMessage_Nested) ProtoMessage() {}
func (m *OldMessage_Nested) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
type NewMessage struct {
Nested *NewMessage_Nested `protobuf:"bytes,1,opt,name=nested" json:"nested,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *NewMessage) Reset() { *m = NewMessage{} }
func (m *NewMessage) String() string { return proto.CompactTextString(m) }
func (*NewMessage) ProtoMessage() {}
func (m *NewMessage) GetNested() *NewMessage_Nested {
if m != nil {
return m.Nested
}
return nil
}
type NewMessage_Nested struct {
Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
FoodGroup *string `protobuf:"bytes,2,opt,name=food_group" json:"food_group,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *NewMessage_Nested) Reset() { *m = NewMessage_Nested{} }
func (m *NewMessage_Nested) String() string { return proto.CompactTextString(m) }
func (*NewMessage_Nested) ProtoMessage() {}
func (m *NewMessage_Nested) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
func (m *NewMessage_Nested) GetFoodGroup() string {
if m != nil && m.FoodGroup != nil {
return *m.FoodGroup
}
return ""
}
type InnerMessage struct {
Host *string `protobuf:"bytes,1,req,name=host" json:"host,omitempty"`
Port *int32 `protobuf:"varint,2,opt,name=port,def=4000" json:"port,omitempty"`
Connected *bool `protobuf:"varint,3,opt,name=connected" json:"connected,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *InnerMessage) Reset() { *m = InnerMessage{} }
func (m *InnerMessage) String() string { return proto.CompactTextString(m) }
func (*InnerMessage) ProtoMessage() {}
const Default_InnerMessage_Port int32 = 4000
func (m *InnerMessage) GetHost() string {
if m != nil && m.Host != nil {
return *m.Host
}
return ""
}
func (m *InnerMessage) GetPort() int32 {
if m != nil && m.Port != nil {
return *m.Port
}
return Default_InnerMessage_Port
}
func (m *InnerMessage) GetConnected() bool {
if m != nil && m.Connected != nil {
return *m.Connected
}
return false
}
type OtherMessage struct {
Key *int64 `protobuf:"varint,1,opt,name=key" json:"key,omitempty"`
Value []byte `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
Weight *float32 `protobuf:"fixed32,3,opt,name=weight" json:"weight,omitempty"`
Inner *InnerMessage `protobuf:"bytes,4,opt,name=inner" json:"inner,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *OtherMessage) Reset() { *m = OtherMessage{} }
func (m *OtherMessage) String() string { return proto.CompactTextString(m) }
func (*OtherMessage) ProtoMessage() {}
func (m *OtherMessage) GetKey() int64 {
if m != nil && m.Key != nil {
return *m.Key
}
return 0
}
func (m *OtherMessage) GetValue() []byte {
if m != nil {
return m.Value
}
return nil
}
func (m *OtherMessage) GetWeight() float32 {
if m != nil && m.Weight != nil {
return *m.Weight
}
return 0
}
func (m *OtherMessage) GetInner() *InnerMessage {
if m != nil {
return m.Inner
}
return nil
}
type MyMessage struct {
Count *int32 `protobuf:"varint,1,req,name=count" json:"count,omitempty"`
Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
Quote *string `protobuf:"bytes,3,opt,name=quote" json:"quote,omitempty"`
Pet []string `protobuf:"bytes,4,rep,name=pet" json:"pet,omitempty"`
Inner *InnerMessage `protobuf:"bytes,5,opt,name=inner" json:"inner,omitempty"`
Others []*OtherMessage `protobuf:"bytes,6,rep,name=others" json:"others,omitempty"`
Bikeshed *MyMessage_Color `protobuf:"varint,7,opt,name=bikeshed,enum=testdata.MyMessage_Color" json:"bikeshed,omitempty"`
Somegroup *MyMessage_SomeGroup `protobuf:"group,8,opt,name=SomeGroup" json:"somegroup,omitempty"`
RepBytes [][]byte `protobuf:"bytes,10,rep,name=rep_bytes" json:"rep_bytes,omitempty"`
Bigfloat *float64 `protobuf:"fixed64,11,opt,name=bigfloat" json:"bigfloat,omitempty"`
XXX_extensions map[int32]proto.Extension `json:"-"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MyMessage) Reset() { *m = MyMessage{} }
func (m *MyMessage) String() string { return proto.CompactTextString(m) }
func (*MyMessage) ProtoMessage() {}
var extRange_MyMessage = []proto.ExtensionRange{
{100, 536870911},
}
func (*MyMessage) ExtensionRangeArray() []proto.ExtensionRange {
return extRange_MyMessage
}
func (m *MyMessage) ExtensionMap() map[int32]proto.Extension {
if m.XXX_extensions == nil {
m.XXX_extensions = make(map[int32]proto.Extension)
}
return m.XXX_extensions
}
func (m *MyMessage) GetCount() int32 {
if m != nil && m.Count != nil {
return *m.Count
}
return 0
}
func (m *MyMessage) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
func (m *MyMessage) GetQuote() string {
if m != nil && m.Quote != nil {
return *m.Quote
}
return ""
}
func (m *MyMessage) GetPet() []string {
if m != nil {
return m.Pet
}
return nil
}
func (m *MyMessage) GetInner() *InnerMessage {
if m != nil {
return m.Inner
}
return nil
}
func (m *MyMessage) GetOthers() []*OtherMessage {
if m != nil {
return m.Others
}
return nil
}
func (m *MyMessage) GetBikeshed() MyMessage_Color {
if m != nil && m.Bikeshed != nil {
return *m.Bikeshed
}
return 0
}
func (m *MyMessage) GetSomegroup() *MyMessage_SomeGroup {
if m != nil {
return m.Somegroup
}
return nil
}
func (m *MyMessage) GetRepBytes() [][]byte {
if m != nil {
return m.RepBytes
}
return nil
}
func (m *MyMessage) GetBigfloat() float64 {
if m != nil && m.Bigfloat != nil {
return *m.Bigfloat
}
return 0
}
type MyMessage_SomeGroup struct {
GroupField *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MyMessage_SomeGroup) Reset() { *m = MyMessage_SomeGroup{} }
func (m *MyMessage_SomeGroup) GetGroupField() int32 {
if m != nil && m.GroupField != nil {
return *m.GroupField
}
return 0
}
type Ext struct {
Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Ext) Reset() { *m = Ext{} }
func (m *Ext) String() string { return proto.CompactTextString(m) }
func (*Ext) ProtoMessage() {}
func (m *Ext) GetData() string {
if m != nil && m.Data != nil {
return *m.Data
}
return ""
}
var E_Ext_More = &proto.ExtensionDesc{
ExtendedType: (*MyMessage)(nil),
ExtensionType: (*Ext)(nil),
Field: 103,
Name: "testdata.Ext.more",
Tag: "bytes,103,opt,name=more",
}
var E_Ext_Text = &proto.ExtensionDesc{
ExtendedType: (*MyMessage)(nil),
ExtensionType: (*string)(nil),
Field: 104,
Name: "testdata.Ext.text",
Tag: "bytes,104,opt,name=text",
}
var E_Ext_Number = &proto.ExtensionDesc{
ExtendedType: (*MyMessage)(nil),
ExtensionType: (*int32)(nil),
Field: 105,
Name: "testdata.Ext.number",
Tag: "varint,105,opt,name=number",
}
type MessageList struct {
Message []*MessageList_Message `protobuf:"group,1,rep" json:"message,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MessageList) Reset() { *m = MessageList{} }
func (m *MessageList) String() string { return proto.CompactTextString(m) }
func (*MessageList) ProtoMessage() {}
func (m *MessageList) GetMessage() []*MessageList_Message {
if m != nil {
return m.Message
}
return nil
}
type MessageList_Message struct {
Name *string `protobuf:"bytes,2,req,name=name" json:"name,omitempty"`
Count *int32 `protobuf:"varint,3,req,name=count" json:"count,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MessageList_Message) Reset() { *m = MessageList_Message{} }
func (m *MessageList_Message) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
func (m *MessageList_Message) GetCount() int32 {
if m != nil && m.Count != nil {
return *m.Count
}
return 0
}
type Strings struct {
StringField *string `protobuf:"bytes,1,opt,name=string_field" json:"string_field,omitempty"`
BytesField []byte `protobuf:"bytes,2,opt,name=bytes_field" json:"bytes_field,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Strings) Reset() { *m = Strings{} }
func (m *Strings) String() string { return proto.CompactTextString(m) }
func (*Strings) ProtoMessage() {}
func (m *Strings) GetStringField() string {
if m != nil && m.StringField != nil {
return *m.StringField
}
return ""
}
func (m *Strings) GetBytesField() []byte {
if m != nil {
return m.BytesField
}
return nil
}
type Defaults struct {
F_Bool *bool `protobuf:"varint,1,opt,def=1" json:"F_Bool,omitempty"`
F_Int32 *int32 `protobuf:"varint,2,opt,def=32" json:"F_Int32,omitempty"`
F_Int64 *int64 `protobuf:"varint,3,opt,def=64" json:"F_Int64,omitempty"`
F_Fixed32 *uint32 `protobuf:"fixed32,4,opt,def=320" json:"F_Fixed32,omitempty"`
F_Fixed64 *uint64 `protobuf:"fixed64,5,opt,def=640" json:"F_Fixed64,omitempty"`
F_Uint32 *uint32 `protobuf:"varint,6,opt,def=3200" json:"F_Uint32,omitempty"`
F_Uint64 *uint64 `protobuf:"varint,7,opt,def=6400" json:"F_Uint64,omitempty"`
F_Float *float32 `protobuf:"fixed32,8,opt,def=314159" json:"F_Float,omitempty"`
F_Double *float64 `protobuf:"fixed64,9,opt,def=271828" json:"F_Double,omitempty"`
F_String *string `protobuf:"bytes,10,opt,def=hello, \"world!\"\n" json:"F_String,omitempty"`
F_Bytes []byte `protobuf:"bytes,11,opt,def=Bignose" json:"F_Bytes,omitempty"`
F_Sint32 *int32 `protobuf:"zigzag32,12,opt,def=-32" json:"F_Sint32,omitempty"`
F_Sint64 *int64 `protobuf:"zigzag64,13,opt,def=-64" json:"F_Sint64,omitempty"`
F_Enum *Defaults_Color `protobuf:"varint,14,opt,enum=testdata.Defaults_Color,def=1" json:"F_Enum,omitempty"`
F_Pinf *float32 `protobuf:"fixed32,15,opt,def=inf" json:"F_Pinf,omitempty"`
F_Ninf *float32 `protobuf:"fixed32,16,opt,def=-inf" json:"F_Ninf,omitempty"`
F_Nan *float32 `protobuf:"fixed32,17,opt,def=nan" json:"F_Nan,omitempty"`
Sub *SubDefaults `protobuf:"bytes,18,opt,name=sub" json:"sub,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Defaults) Reset() { *m = Defaults{} }
func (m *Defaults) String() string { return proto.CompactTextString(m) }
func (*Defaults) ProtoMessage() {}
const Default_Defaults_F_Bool bool = true
const Default_Defaults_F_Int32 int32 = 32
const Default_Defaults_F_Int64 int64 = 64
const Default_Defaults_F_Fixed32 uint32 = 320
const Default_Defaults_F_Fixed64 uint64 = 640
const Default_Defaults_F_Uint32 uint32 = 3200
const Default_Defaults_F_Uint64 uint64 = 6400
const Default_Defaults_F_Float float32 = 314159
const Default_Defaults_F_Double float64 = 271828
const Default_Defaults_F_String string = "hello, \"world!\"\n"
var Default_Defaults_F_Bytes []byte = []byte("Bignose")
const Default_Defaults_F_Sint32 int32 = -32
const Default_Defaults_F_Sint64 int64 = -64
const Default_Defaults_F_Enum Defaults_Color = Defaults_GREEN
var Default_Defaults_F_Pinf float32 = float32(math.Inf(1))
var Default_Defaults_F_Ninf float32 = float32(math.Inf(-1))
var Default_Defaults_F_Nan float32 = float32(math.NaN())
func (m *Defaults) GetF_Bool() bool {
if m != nil && m.F_Bool != nil {
return *m.F_Bool
}
return Default_Defaults_F_Bool
}
func (m *Defaults) GetF_Int32() int32 {
if m != nil && m.F_Int32 != nil {
return *m.F_Int32
}
return Default_Defaults_F_Int32
}
func (m *Defaults) GetF_Int64() int64 {
if m != nil && m.F_Int64 != nil {
return *m.F_Int64
}
return Default_Defaults_F_Int64
}
func (m *Defaults) GetF_Fixed32() uint32 {
if m != nil && m.F_Fixed32 != nil {
return *m.F_Fixed32
}
return Default_Defaults_F_Fixed32
}
func (m *Defaults) GetF_Fixed64() uint64 {
if m != nil && m.F_Fixed64 != nil {
return *m.F_Fixed64
}
return Default_Defaults_F_Fixed64
}
func (m *Defaults) GetF_Uint32() uint32 {
if m != nil && m.F_Uint32 != nil {
return *m.F_Uint32
}
return Default_Defaults_F_Uint32
}
func (m *Defaults) GetF_Uint64() uint64 {
if m != nil && m.F_Uint64 != nil {
return *m.F_Uint64
}
return Default_Defaults_F_Uint64
}
func (m *Defaults) GetF_Float() float32 {
if m != nil && m.F_Float != nil {
return *m.F_Float
}
return Default_Defaults_F_Float
}
func (m *Defaults) GetF_Double() float64 {
if m != nil && m.F_Double != nil {
return *m.F_Double
}
return Default_Defaults_F_Double
}
func (m *Defaults) GetF_String() string {
if m != nil && m.F_String != nil {
return *m.F_String
}
return Default_Defaults_F_String
}
func (m *Defaults) GetF_Bytes() []byte {
if m != nil && m.F_Bytes != nil {
return m.F_Bytes
}
return append([]byte(nil), Default_Defaults_F_Bytes...)
}
func (m *Defaults) GetF_Sint32() int32 {
if m != nil && m.F_Sint32 != nil {
return *m.F_Sint32
}
return Default_Defaults_F_Sint32
}
func (m *Defaults) GetF_Sint64() int64 {
if m != nil && m.F_Sint64 != nil {
return *m.F_Sint64
}
return Default_Defaults_F_Sint64
}
func (m *Defaults) GetF_Enum() Defaults_Color {
if m != nil && m.F_Enum != nil {
return *m.F_Enum
}
return Default_Defaults_F_Enum
}
func (m *Defaults) GetF_Pinf() float32 {
if m != nil && m.F_Pinf != nil {
return *m.F_Pinf
}
return Default_Defaults_F_Pinf
}
func (m *Defaults) GetF_Ninf() float32 {
if m != nil && m.F_Ninf != nil {
return *m.F_Ninf
}
return Default_Defaults_F_Ninf
}
func (m *Defaults) GetF_Nan() float32 {
if m != nil && m.F_Nan != nil {
return *m.F_Nan
}
return Default_Defaults_F_Nan
}
func (m *Defaults) GetSub() *SubDefaults {
if m != nil {
return m.Sub
}
return nil
}
type SubDefaults struct {
N *int64 `protobuf:"varint,1,opt,name=n,def=7" json:"n,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *SubDefaults) Reset() { *m = SubDefaults{} }
func (m *SubDefaults) String() string { return proto.CompactTextString(m) }
func (*SubDefaults) ProtoMessage() {}
const Default_SubDefaults_N int64 = 7
func (m *SubDefaults) GetN() int64 {
if m != nil && m.N != nil {
return *m.N
}
return Default_SubDefaults_N
}
type RepeatedEnum struct {
Color []RepeatedEnum_Color `protobuf:"varint,1,rep,name=color,enum=testdata.RepeatedEnum_Color" json:"color,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *RepeatedEnum) Reset() { *m = RepeatedEnum{} }
func (m *RepeatedEnum) String() string { return proto.CompactTextString(m) }
func (*RepeatedEnum) ProtoMessage() {}
func (m *RepeatedEnum) GetColor() []RepeatedEnum_Color {
if m != nil {
return m.Color
}
return nil
}
type MoreRepeated struct {
Bools []bool `protobuf:"varint,1,rep,name=bools" json:"bools,omitempty"`
BoolsPacked []bool `protobuf:"varint,2,rep,packed,name=bools_packed" json:"bools_packed,omitempty"`
Ints []int32 `protobuf:"varint,3,rep,name=ints" json:"ints,omitempty"`
IntsPacked []int32 `protobuf:"varint,4,rep,packed,name=ints_packed" json:"ints_packed,omitempty"`
Strings []string `protobuf:"bytes,5,rep,name=strings" json:"strings,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *MoreRepeated) Reset() { *m = MoreRepeated{} }
func (m *MoreRepeated) String() string { return proto.CompactTextString(m) }
func (*MoreRepeated) ProtoMessage() {}
func (m *MoreRepeated) GetBools() []bool {
if m != nil {
return m.Bools
}
return nil
}
func (m *MoreRepeated) GetBoolsPacked() []bool {
if m != nil {
return m.BoolsPacked
}
return nil
}
func (m *MoreRepeated) GetInts() []int32 {
if m != nil {
return m.Ints
}
return nil
}
func (m *MoreRepeated) GetIntsPacked() []int32 {
if m != nil {
return m.IntsPacked
}
return nil
}
func (m *MoreRepeated) GetStrings() []string {
if m != nil {
return m.Strings
}
return nil
}
type GroupOld struct {
G *GroupOld_G `protobuf:"group,1,opt" json:"g,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GroupOld) Reset() { *m = GroupOld{} }
func (m *GroupOld) String() string { return proto.CompactTextString(m) }
func (*GroupOld) ProtoMessage() {}
func (m *GroupOld) GetG() *GroupOld_G {
if m != nil {
return m.G
}
return nil
}
type GroupOld_G struct {
X *int32 `protobuf:"varint,2,opt,name=x" json:"x,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GroupOld_G) Reset() { *m = GroupOld_G{} }
func (m *GroupOld_G) GetX() int32 {
if m != nil && m.X != nil {
return *m.X
}
return 0
}
type GroupNew struct {
G *GroupNew_G `protobuf:"group,1,opt" json:"g,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GroupNew) Reset() { *m = GroupNew{} }
func (m *GroupNew) String() string { return proto.CompactTextString(m) }
func (*GroupNew) ProtoMessage() {}
func (m *GroupNew) GetG() *GroupNew_G {
if m != nil {
return m.G
}
return nil
}
type GroupNew_G struct {
X *int32 `protobuf:"varint,2,opt,name=x" json:"x,omitempty"`
Y *int32 `protobuf:"varint,3,opt,name=y" json:"y,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GroupNew_G) Reset() { *m = GroupNew_G{} }
func (m *GroupNew_G) GetX() int32 {
if m != nil && m.X != nil {
return *m.X
}
return 0
}
func (m *GroupNew_G) GetY() int32 {
if m != nil && m.Y != nil {
return *m.Y
}
return 0
}
var E_Greeting = &proto.ExtensionDesc{
ExtendedType: (*MyMessage)(nil),
ExtensionType: ([]string)(nil),
Field: 106,
Name: "testdata.greeting",
Tag: "bytes,106,rep,name=greeting",
}
func init() {
proto.RegisterEnum("testdata.FOO", FOO_name, FOO_value)
proto.RegisterEnum("testdata.GoTest_KIND", GoTest_KIND_name, GoTest_KIND_value)
proto.RegisterEnum("testdata.MyMessage_Color", MyMessage_Color_name, MyMessage_Color_value)
proto.RegisterEnum("testdata.Defaults_Color", Defaults_Color_name, Defaults_Color_value)
proto.RegisterEnum("testdata.RepeatedEnum_Color", RepeatedEnum_Color_name, RepeatedEnum_Color_value)
proto.RegisterExtension(E_Ext_More)
proto.RegisterExtension(E_Ext_Text)
proto.RegisterExtension(E_Ext_Number)
proto.RegisterExtension(E_Greeting)
}
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A feature-rich test file for the protocol compiler and libraries.
syntax = "proto2";
package testdata;
enum FOO { FOO1 = 1; };
message GoEnum {
required FOO foo = 1;
}
message GoTestField {
required string Label = 1;
required string Type = 2;
}
message GoTest {
// An enum, for completeness.
enum KIND {
VOID = 0;
// Basic types
BOOL = 1;
BYTES = 2;
FINGERPRINT = 3;
FLOAT = 4;
INT = 5;
STRING = 6;
TIME = 7;
// Groupings
TUPLE = 8;
ARRAY = 9;
MAP = 10;
// Table types
TABLE = 11;
// Functions
FUNCTION = 12; // last tag
};
// Some typical parameters
required KIND Kind = 1;
optional string Table = 2;
optional int32 Param = 3;
// Required, repeated and optional foreign fields.
required GoTestField RequiredField = 4;
repeated GoTestField RepeatedField = 5;
optional GoTestField OptionalField = 6;
// Required fields of all basic types
required bool F_Bool_required = 10;
required int32 F_Int32_required = 11;
required int64 F_Int64_required = 12;
required fixed32 F_Fixed32_required = 13;
required fixed64 F_Fixed64_required = 14;
required uint32 F_Uint32_required = 15;
required uint64 F_Uint64_required = 16;
required float F_Float_required = 17;
required double F_Double_required = 18;
required string F_String_required = 19;
required bytes F_Bytes_required = 101;
required sint32 F_Sint32_required = 102;
required sint64 F_Sint64_required = 103;
// Repeated fields of all basic types
repeated bool F_Bool_repeated = 20;
repeated int32 F_Int32_repeated = 21;
repeated int64 F_Int64_repeated = 22;
repeated fixed32 F_Fixed32_repeated = 23;
repeated fixed64 F_Fixed64_repeated = 24;
repeated uint32 F_Uint32_repeated = 25;
repeated uint64 F_Uint64_repeated = 26;
repeated float F_Float_repeated = 27;
repeated double F_Double_repeated = 28;
repeated string F_String_repeated = 29;
repeated bytes F_Bytes_repeated = 201;
repeated sint32 F_Sint32_repeated = 202;
repeated sint64 F_Sint64_repeated = 203;
// Optional fields of all basic types
optional bool F_Bool_optional = 30;
optional int32 F_Int32_optional = 31;
optional int64 F_Int64_optional = 32;
optional fixed32 F_Fixed32_optional = 33;
optional fixed64 F_Fixed64_optional = 34;
optional uint32 F_Uint32_optional = 35;
optional uint64 F_Uint64_optional = 36;
optional float F_Float_optional = 37;
optional double F_Double_optional = 38;
optional string F_String_optional = 39;
optional bytes F_Bytes_optional = 301;
optional sint32 F_Sint32_optional = 302;
optional sint64 F_Sint64_optional = 303;
// Default-valued fields of all basic types
optional bool F_Bool_defaulted = 40 [default=true];
optional int32 F_Int32_defaulted = 41 [default=32];
optional int64 F_Int64_defaulted = 42 [default=64];
optional fixed32 F_Fixed32_defaulted = 43 [default=320];
optional fixed64 F_Fixed64_defaulted = 44 [default=640];
optional uint32 F_Uint32_defaulted = 45 [default=3200];
optional uint64 F_Uint64_defaulted = 46 [default=6400];
optional float F_Float_defaulted = 47 [default=314159.];
optional double F_Double_defaulted = 48 [default=271828.];
optional string F_String_defaulted = 49 [default="hello, \"world!\"\n"];
optional bytes F_Bytes_defaulted = 401 [default="Bignose"];
optional sint32 F_Sint32_defaulted = 402 [default = -32];
optional sint64 F_Sint64_defaulted = 403 [default = -64];
// Packed repeated fields (no string or bytes).
repeated bool F_Bool_repeated_packed = 50 [packed=true];
repeated int32 F_Int32_repeated_packed = 51 [packed=true];
repeated int64 F_Int64_repeated_packed = 52 [packed=true];
repeated fixed32 F_Fixed32_repeated_packed = 53 [packed=true];
repeated fixed64 F_Fixed64_repeated_packed = 54 [packed=true];
repeated uint32 F_Uint32_repeated_packed = 55 [packed=true];
repeated uint64 F_Uint64_repeated_packed = 56 [packed=true];
repeated float F_Float_repeated_packed = 57 [packed=true];
repeated double F_Double_repeated_packed = 58 [packed=true];
repeated sint32 F_Sint32_repeated_packed = 502 [packed=true];
repeated sint64 F_Sint64_repeated_packed = 503 [packed=true];
// Required, repeated, and optional groups.
required group RequiredGroup = 70 {
required string RequiredField = 71;
};
repeated group RepeatedGroup = 80 {
required string RequiredField = 81;
};
optional group OptionalGroup = 90 {
required string RequiredField = 91;
};
}
// For testing skipping of unrecognized fields.
// Numbers are all big, larger than tag numbers in GoTestField,
// the message used in the corresponding test.
message GoSkipTest {
required int32 skip_int32 = 11;
required fixed32 skip_fixed32 = 12;
required fixed64 skip_fixed64 = 13;
required string skip_string = 14;
required group SkipGroup = 15 {
required int32 group_int32 = 16;
required string group_string = 17;
}
}
// For testing packed/non-packed decoder switching.
// A serialized instance of one should be deserializable as the other.
message NonPackedTest {
repeated int32 a = 1;
}
message PackedTest {
repeated int32 b = 1 [packed=true];
}
message MaxTag {
// Maximum possible tag number.
optional string last_field = 536870911;
}
message OldMessage {
message Nested {
optional string name = 1;
}
optional Nested nested = 1;
optional int32 num = 2;
}
// NewMessage is wire compatible with OldMessage;
// imagine it as a future version.
message NewMessage {
message Nested {
optional string name = 1;
optional string food_group = 2;
}
optional Nested nested = 1;
// This is an int32 in OldMessage.
optional int64 num = 2;
}
// Smaller tests for ASCII formatting.
message InnerMessage {
required string host = 1;
optional int32 port = 2 [default=4000];
optional bool connected = 3;
}
message OtherMessage {
optional int64 key = 1;
optional bytes value = 2;
optional float weight = 3;
optional InnerMessage inner = 4;
}
message MyMessage {
required int32 count = 1;
optional string name = 2;
optional string quote = 3;
repeated string pet = 4;
optional InnerMessage inner = 5;
repeated OtherMessage others = 6;
repeated InnerMessage rep_inner = 12;
enum Color {
RED = 0;
GREEN = 1;
BLUE = 2;
};
optional Color bikeshed = 7;
optional group SomeGroup = 8 {
optional int32 group_field = 9;
}
// This field becomes [][]byte in the generated code.
repeated bytes rep_bytes = 10;
optional double bigfloat = 11;
extensions 100 to max;
}
message Ext {
extend MyMessage {
optional Ext more = 103;
optional string text = 104;
optional int32 number = 105;
}
optional string data = 1;
}
extend MyMessage {
repeated string greeting = 106;
}
message DefaultsMessage {
enum DefaultsEnum {
ZERO = 0;
ONE = 1;
TWO = 2;
};
extensions 100 to max;
}
extend DefaultsMessage {
optional double no_default_double = 101;
optional float no_default_float = 102;
optional int32 no_default_int32 = 103;
optional int64 no_default_int64 = 104;
optional uint32 no_default_uint32 = 105;
optional uint64 no_default_uint64 = 106;
optional sint32 no_default_sint32 = 107;
optional sint64 no_default_sint64 = 108;
optional fixed32 no_default_fixed32 = 109;
optional fixed64 no_default_fixed64 = 110;
optional sfixed32 no_default_sfixed32 = 111;
optional sfixed64 no_default_sfixed64 = 112;
optional bool no_default_bool = 113;
optional string no_default_string = 114;
optional bytes no_default_bytes = 115;
optional DefaultsMessage.DefaultsEnum no_default_enum = 116;
optional double default_double = 201 [default = 3.1415];
optional float default_float = 202 [default = 3.14];
optional int32 default_int32 = 203 [default = 42];
optional int64 default_int64 = 204 [default = 43];
optional uint32 default_uint32 = 205 [default = 44];
optional uint64 default_uint64 = 206 [default = 45];
optional sint32 default_sint32 = 207 [default = 46];
optional sint64 default_sint64 = 208 [default = 47];
optional fixed32 default_fixed32 = 209 [default = 48];
optional fixed64 default_fixed64 = 210 [default = 49];
optional sfixed32 default_sfixed32 = 211 [default = 50];
optional sfixed64 default_sfixed64 = 212 [default = 51];
optional bool default_bool = 213 [default = true];
optional string default_string = 214 [default = "Hello, string"];
optional bytes default_bytes = 215 [default = "Hello, bytes"];
optional DefaultsMessage.DefaultsEnum default_enum = 216 [default = ONE];
}
message MyMessageSet {
option message_set_wire_format = true;
extensions 100 to max;
}
message Empty {
}
extend MyMessageSet {
optional Empty x201 = 201;
optional Empty x202 = 202;
optional Empty x203 = 203;
optional Empty x204 = 204;
optional Empty x205 = 205;
optional Empty x206 = 206;
optional Empty x207 = 207;
optional Empty x208 = 208;
optional Empty x209 = 209;
optional Empty x210 = 210;
optional Empty x211 = 211;
optional Empty x212 = 212;
optional Empty x213 = 213;
optional Empty x214 = 214;
optional Empty x215 = 215;
optional Empty x216 = 216;
optional Empty x217 = 217;
optional Empty x218 = 218;
optional Empty x219 = 219;
optional Empty x220 = 220;
optional Empty x221 = 221;
optional Empty x222 = 222;
optional Empty x223 = 223;
optional Empty x224 = 224;
optional Empty x225 = 225;
optional Empty x226 = 226;
optional Empty x227 = 227;
optional Empty x228 = 228;
optional Empty x229 = 229;
optional Empty x230 = 230;
optional Empty x231 = 231;
optional Empty x232 = 232;
optional Empty x233 = 233;
optional Empty x234 = 234;
optional Empty x235 = 235;
optional Empty x236 = 236;
optional Empty x237 = 237;
optional Empty x238 = 238;
optional Empty x239 = 239;
optional Empty x240 = 240;
optional Empty x241 = 241;
optional Empty x242 = 242;
optional Empty x243 = 243;
optional Empty x244 = 244;
optional Empty x245 = 245;
optional Empty x246 = 246;
optional Empty x247 = 247;
optional Empty x248 = 248;
optional Empty x249 = 249;
optional Empty x250 = 250;
}
message MessageList {
repeated group Message = 1 {
required string name = 2;
required int32 count = 3;
}
}
message Strings {
optional string string_field = 1;
optional bytes bytes_field = 2;
}
message Defaults {
enum Color {
RED = 0;
GREEN = 1;
BLUE = 2;
}
// Default-valued fields of all basic types.
// Same as GoTest, but copied here to make testing easier.
optional bool F_Bool = 1 [default=true];
optional int32 F_Int32 = 2 [default=32];
optional int64 F_Int64 = 3 [default=64];
optional fixed32 F_Fixed32 = 4 [default=320];
optional fixed64 F_Fixed64 = 5 [default=640];
optional uint32 F_Uint32 = 6 [default=3200];
optional uint64 F_Uint64 = 7 [default=6400];
optional float F_Float = 8 [default=314159.];
optional double F_Double = 9 [default=271828.];
optional string F_String = 10 [default="hello, \"world!\"\n"];
optional bytes F_Bytes = 11 [default="Bignose"];
optional sint32 F_Sint32 = 12 [default=-32];
optional sint64 F_Sint64 = 13 [default=-64];
optional Color F_Enum = 14 [default=GREEN];
// More fields with crazy defaults.
optional float F_Pinf = 15 [default=inf];
optional float F_Ninf = 16 [default=-inf];
optional float F_Nan = 17 [default=nan];
// Sub-message.
optional SubDefaults sub = 18;
// Redundant but explicit defaults.
optional string str_zero = 19 [default=""];
}
message SubDefaults {
optional int64 n = 1 [default=7];
}
message RepeatedEnum {
enum Color {
RED = 1;
}
repeated Color color = 1;
}
message MoreRepeated {
repeated bool bools = 1;
repeated bool bools_packed = 2 [packed=true];
repeated int32 ints = 3;
repeated int32 ints_packed = 4 [packed=true];
repeated int64 int64s_packed = 7 [packed=true];
repeated string strings = 5;
repeated fixed32 fixeds = 6;
}
// GroupOld and GroupNew have the same wire format.
// GroupNew has a new field inside a group.
message GroupOld {
optional group G = 101 {
optional int32 x = 2;
}
}
message GroupNew {
optional group G = 101 {
optional int32 x = 2;
optional int32 y = 3;
}
}
message FloatingPoint {
required double f = 1;
}
message MessageWithMap {
map<int32, string> name_mapping = 1;
map<sint64, FloatingPoint> msg_mapping = 2;
map<bool, bytes> byte_mapping = 3;
map<string, string> str_to_str = 4;
}
message Communique {
optional bool make_me_cry = 1;
// This is a oneof, called "union".
oneof union {
int32 number = 5;
string name = 6;
bytes data = 7;
double temp_c = 8;
MyMessage.Color col = 9;
Strings msg = 10;
}
}
// Extensions for Protocol Buffers to create more go like structures.
//
// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
// http://github.com/gogo/protobuf/gogoproto
//
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
// Functions for writing the text protocol buffer format.
import (
"bufio"
"bytes"
"encoding"
"errors"
"fmt"
"io"
"log"
"math"
"reflect"
"sort"
"strings"
)
var (
newline = []byte("\n")
spaces = []byte(" ")
gtNewline = []byte(">\n")
endBraceNewline = []byte("}\n")
backslashN = []byte{'\\', 'n'}
backslashR = []byte{'\\', 'r'}
backslashT = []byte{'\\', 't'}
backslashDQ = []byte{'\\', '"'}
backslashBS = []byte{'\\', '\\'}
posInf = []byte("inf")
negInf = []byte("-inf")
nan = []byte("nan")
)
type writer interface {
io.Writer
WriteByte(byte) error
}
// textWriter is an io.Writer that tracks its indentation level.
type textWriter struct {
ind int
complete bool // if the current position is a complete line
compact bool // whether to write out as a one-liner
w writer
}
func (w *textWriter) WriteString(s string) (n int, err error) {
if !strings.Contains(s, "\n") {
if !w.compact && w.complete {
w.writeIndent()
}
w.complete = false
return io.WriteString(w.w, s)
}
// WriteString is typically called without newlines, so this
// codepath and its copy are rare. We copy to avoid
// duplicating all of Write's logic here.
return w.Write([]byte(s))
}
func (w *textWriter) Write(p []byte) (n int, err error) {
newlines := bytes.Count(p, newline)
if newlines == 0 {
if !w.compact && w.complete {
w.writeIndent()
}
n, err = w.w.Write(p)
w.complete = false
return n, err
}
frags := bytes.SplitN(p, newline, newlines+1)
if w.compact {
for i, frag := range frags {
if i > 0 {
if err := w.w.WriteByte(' '); err != nil {
return n, err
}
n++
}
nn, err := w.w.Write(frag)
n += nn
if err != nil {
return n, err
}
}
return n, nil
}
for i, frag := range frags {
if w.complete {
w.writeIndent()
}
nn, err := w.w.Write(frag)
n += nn
if err != nil {
return n, err
}
if i+1 < len(frags) {
if err := w.w.WriteByte('\n'); err != nil {
return n, err
}
n++
}
}
w.complete = len(frags[len(frags)-1]) == 0
return n, nil
}
func (w *textWriter) WriteByte(c byte) error {
if w.compact && c == '\n' {
c = ' '
}
if !w.compact && w.complete {
w.writeIndent()
}
err := w.w.WriteByte(c)
w.complete = c == '\n'
return err
}
func (w *textWriter) indent() { w.ind++ }
func (w *textWriter) unindent() {
if w.ind == 0 {
log.Printf("proto: textWriter unindented too far")
return
}
w.ind--
}
func writeName(w *textWriter, props *Properties) error {
if _, err := w.WriteString(props.OrigName); err != nil {
return err
}
if props.Wire != "group" {
return w.WriteByte(':')
}
return nil
}
var (
messageSetType = reflect.TypeOf((*MessageSet)(nil)).Elem()
)
// raw is the interface satisfied by RawMessage.
type raw interface {
Bytes() []byte
}
func writeStruct(w *textWriter, sv reflect.Value) error {
if sv.Type() == messageSetType {
return writeMessageSet(w, sv.Addr().Interface().(*MessageSet))
}
st := sv.Type()
sprops := GetProperties(st)
for i := 0; i < sv.NumField(); i++ {
fv := sv.Field(i)
props := sprops.Prop[i]
name := st.Field(i).Name
if strings.HasPrefix(name, "XXX_") {
// There are two XXX_ fields:
// XXX_unrecognized []byte
// XXX_extensions map[int32]proto.Extension
// The first is handled here;
// the second is handled at the bottom of this function.
if name == "XXX_unrecognized" && !fv.IsNil() {
if err := writeUnknownStruct(w, fv.Interface().([]byte)); err != nil {
return err
}
}
continue
}
if fv.Kind() == reflect.Ptr && fv.IsNil() {
// Field not filled in. This could be an optional field or
// a required field that wasn't filled in. Either way, there
// isn't anything we can show for it.
continue
}
if fv.Kind() == reflect.Slice && fv.IsNil() {
// Repeated field that is empty, or a bytes field that is unused.
continue
}
if props.Repeated && fv.Kind() == reflect.Slice {
// Repeated field.
for j := 0; j < fv.Len(); j++ {
if err := writeName(w, props); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
v := fv.Index(j)
if v.Kind() == reflect.Ptr && v.IsNil() {
// A nil message in a repeated field is not valid,
// but we can handle that more gracefully than panicking.
if _, err := w.Write([]byte("<nil>\n")); err != nil {
return err
}
continue
}
if len(props.Enum) > 0 {
if err := writeEnum(w, v, props); err != nil {
return err
}
} else if err := writeAny(w, v, props); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
continue
}
if fv.Kind() == reflect.Map {
// Map fields are rendered as a repeated struct with key/value fields.
keys := fv.MapKeys()
sort.Sort(mapKeys(keys))
for _, key := range keys {
val := fv.MapIndex(key)
if err := writeName(w, props); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
// open struct
if err := w.WriteByte('<'); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte('\n'); err != nil {
return err
}
}
w.indent()
// key
if _, err := w.WriteString("key:"); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
if err := writeAny(w, key, props.mkeyprop); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
// nil values aren't legal, but we can avoid panicking because of them.
if val.Kind() != reflect.Ptr || !val.IsNil() {
// value
if _, err := w.WriteString("value:"); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
if err := writeAny(w, val, props.mvalprop); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
// close struct
w.unindent()
if err := w.WriteByte('>'); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
continue
}
if props.proto3 && fv.Kind() == reflect.Slice && fv.Len() == 0 {
// empty bytes field
continue
}
if props.proto3 && fv.Kind() != reflect.Ptr && fv.Kind() != reflect.Slice {
// proto3 non-repeated scalar field; skip if zero value
if isProto3Zero(fv) {
continue
}
}
if fv.Kind() == reflect.Interface {
// Check if it is a oneof.
if st.Field(i).Tag.Get("protobuf_oneof") != "" {
// fv is nil, or holds a pointer to generated struct.
// That generated struct has exactly one field,
// which has a protobuf struct tag.
if fv.IsNil() {
continue
}
inner := fv.Elem().Elem() // interface -> *T -> T
tag := inner.Type().Field(0).Tag.Get("protobuf")
props.Parse(tag) // Overwrite the outer props.
// Write the value in the oneof, not the oneof itself.
fv = inner.Field(0)
// Special case to cope with malformed messages gracefully:
// If the value in the oneof is a nil pointer, don't panic
// in writeAny.
if fv.Kind() == reflect.Ptr && fv.IsNil() {
// Use errors.New so writeAny won't render quotes.
msg := errors.New("/* nil */")
fv = reflect.ValueOf(&msg).Elem()
}
}
}
if err := writeName(w, props); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
if b, ok := fv.Interface().(raw); ok {
if err := writeRaw(w, b.Bytes()); err != nil {
return err
}
continue
}
if len(props.Enum) > 0 {
if err := writeEnum(w, fv, props); err != nil {
return err
}
} else if err := writeAny(w, fv, props); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
// Extensions (the XXX_extensions field).
pv := sv.Addr()
if pv.Type().Implements(extendableProtoType) {
if err := writeExtensions(w, pv); err != nil {
return err
}
}
return nil
}
// writeRaw writes an uninterpreted raw message.
func writeRaw(w *textWriter, b []byte) error {
if err := w.WriteByte('<'); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte('\n'); err != nil {
return err
}
}
w.indent()
if err := writeUnknownStruct(w, b); err != nil {
return err
}
w.unindent()
if err := w.WriteByte('>'); err != nil {
return err
}
return nil
}
// writeAny writes an arbitrary field.
func writeAny(w *textWriter, v reflect.Value, props *Properties) error {
v = reflect.Indirect(v)
if props != nil && len(props.CustomType) > 0 {
custom, ok := v.Interface().(Marshaler)
if ok {
data, err := custom.Marshal()
if err != nil {
return err
}
if err := writeString(w, string(data)); err != nil {
return err
}
return nil
}
}
// Floats have special cases.
if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 {
x := v.Float()
var b []byte
switch {
case math.IsInf(x, 1):
b = posInf
case math.IsInf(x, -1):
b = negInf
case math.IsNaN(x):
b = nan
}
if b != nil {
_, err := w.Write(b)
return err
}
// Other values are handled below.
}
// We don't attempt to serialise every possible value type; only those
// that can occur in protocol buffers.
switch v.Kind() {
case reflect.Slice:
// Should only be a []byte; repeated fields are handled in writeStruct.
if err := writeString(w, string(v.Bytes())); err != nil {
return err
}
case reflect.String:
if err := writeString(w, v.String()); err != nil {
return err
}
case reflect.Struct:
// Required/optional group/message.
var bra, ket byte = '<', '>'
if props != nil && props.Wire == "group" {
bra, ket = '{', '}'
}
if err := w.WriteByte(bra); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte('\n'); err != nil {
return err
}
}
w.indent()
if tm, ok := v.Interface().(encoding.TextMarshaler); ok {
text, err := tm.MarshalText()
if err != nil {
return err
}
if _, err = w.Write(text); err != nil {
return err
}
} else if err := writeStruct(w, v); err != nil {
return err
}
w.unindent()
if err := w.WriteByte(ket); err != nil {
return err
}
default:
_, err := fmt.Fprint(w, v.Interface())
return err
}
return nil
}
// equivalent to C's isprint.
func isprint(c byte) bool {
return c >= 0x20 && c < 0x7f
}
// writeString writes a string in the protocol buffer text format.
// It is similar to strconv.Quote except we don't use Go escape sequences,
// we treat the string as a byte sequence, and we use octal escapes.
// These differences are to maintain interoperability with the other
// languages' implementations of the text format.
func writeString(w *textWriter, s string) error {
// use WriteByte here to get any needed indent
if err := w.WriteByte('"'); err != nil {
return err
}
// Loop over the bytes, not the runes.
for i := 0; i < len(s); i++ {
var err error
// Divergence from C++: we don't escape apostrophes.
// There's no need to escape them, and the C++ parser
// copes with a naked apostrophe.
switch c := s[i]; c {
case '\n':
_, err = w.w.Write(backslashN)
case '\r':
_, err = w.w.Write(backslashR)
case '\t':
_, err = w.w.Write(backslashT)
case '"':
_, err = w.w.Write(backslashDQ)
case '\\':
_, err = w.w.Write(backslashBS)
default:
if isprint(c) {
err = w.w.WriteByte(c)
} else {
_, err = fmt.Fprintf(w.w, "\\%03o", c)
}
}
if err != nil {
return err
}
}
return w.WriteByte('"')
}
func writeMessageSet(w *textWriter, ms *MessageSet) error {
for _, item := range ms.Item {
id := *item.TypeId
if msd, ok := messageSetMap[id]; ok {
// Known message set type.
if _, err := fmt.Fprintf(w, "[%s]: <\n", msd.name); err != nil {
return err
}
w.indent()
pb := reflect.New(msd.t.Elem())
if err := Unmarshal(item.Message, pb.Interface().(Message)); err != nil {
if _, ferr := fmt.Fprintf(w, "/* bad message: %v */\n", err); ferr != nil {
return ferr
}
} else {
if err := writeStruct(w, pb.Elem()); err != nil {
return err
}
}
} else {
// Unknown type.
if _, err := fmt.Fprintf(w, "[%d]: <\n", id); err != nil {
return err
}
w.indent()
if err := writeUnknownStruct(w, item.Message); err != nil {
return err
}
}
w.unindent()
if _, err := w.Write(gtNewline); err != nil {
return err
}
}
return nil
}
func writeUnknownStruct(w *textWriter, data []byte) error {
if !w.compact {
if _, err := fmt.Fprintf(w, "/* %d unknown bytes */\n", len(data)); err != nil {
return err
}
}
b := NewBuffer(data)
for b.index < len(b.buf) {
x, err := b.DecodeVarint()
if err != nil {
_, ferr := fmt.Fprintf(w, "/* %v */\n", err)
return ferr
}
wire, tag := x&7, x>>3
if wire == WireEndGroup {
w.unindent()
if _, werr := w.Write(endBraceNewline); werr != nil {
return werr
}
continue
}
if _, ferr := fmt.Fprint(w, tag); ferr != nil {
return ferr
}
if wire != WireStartGroup {
if err := w.WriteByte(':'); err != nil {
return err
}
}
if !w.compact || wire == WireStartGroup {
if err := w.WriteByte(' '); err != nil {
return err
}
}
switch wire {
case WireBytes:
buf, e := b.DecodeRawBytes(false)
if e == nil {
_, err = fmt.Fprintf(w, "%q", buf)
} else {
_, err = fmt.Fprintf(w, "/* %v */", e)
}
case WireFixed32:
x, err = b.DecodeFixed32()
err = writeUnknownInt(w, x, err)
case WireFixed64:
x, err = b.DecodeFixed64()
err = writeUnknownInt(w, x, err)
case WireStartGroup:
err = w.WriteByte('{')
w.indent()
case WireVarint:
x, err = b.DecodeVarint()
err = writeUnknownInt(w, x, err)
default:
_, err = fmt.Fprintf(w, "/* unknown wire type %d */", wire)
}
if err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
return nil
}
func writeUnknownInt(w *textWriter, x uint64, err error) error {
if err == nil {
_, err = fmt.Fprint(w, x)
} else {
_, err = fmt.Fprintf(w, "/* %v */", err)
}
return err
}
type int32Slice []int32
func (s int32Slice) Len() int { return len(s) }
func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] }
func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// writeExtensions writes all the extensions in pv.
// pv is assumed to be a pointer to a protocol message struct that is extendable.
func writeExtensions(w *textWriter, pv reflect.Value) error {
emap := extensionMaps[pv.Type().Elem()]
ep := pv.Interface().(extendableProto)
// Order the extensions by ID.
// This isn't strictly necessary, but it will give us
// canonical output, which will also make testing easier.
var m map[int32]Extension
if em, ok := ep.(extensionsMap); ok {
m = em.ExtensionMap()
} else if em, ok := ep.(extensionsBytes); ok {
eb := em.GetExtensions()
var err error
m, err = BytesToExtensionsMap(*eb)
if err != nil {
return err
}
}
ids := make([]int32, 0, len(m))
for id := range m {
ids = append(ids, id)
}
sort.Sort(int32Slice(ids))
for _, extNum := range ids {
ext := m[extNum]
var desc *ExtensionDesc
if emap != nil {
desc = emap[extNum]
}
if desc == nil {
// Unknown extension.
if err := writeUnknownStruct(w, ext.enc); err != nil {
return err
}
continue
}
pb, err := GetExtension(ep, desc)
if err != nil {
return fmt.Errorf("failed getting extension: %v", err)
}
// Repeated extensions will appear as a slice.
if !desc.repeated() {
if err := writeExtension(w, desc.Name, pb); err != nil {
return err
}
} else {
v := reflect.ValueOf(pb)
for i := 0; i < v.Len(); i++ {
if err := writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil {
return err
}
}
}
}
return nil
}
func writeExtension(w *textWriter, name string, pb interface{}) error {
if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
if err := writeAny(w, reflect.ValueOf(pb), nil); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
return nil
}
func (w *textWriter) writeIndent() {
if !w.complete {
return
}
remain := w.ind * 2
for remain > 0 {
n := remain
if n > len(spaces) {
n = len(spaces)
}
w.w.Write(spaces[:n])
remain -= n
}
w.complete = false
}
func marshalText(w io.Writer, pb Message, compact bool) error {
val := reflect.ValueOf(pb)
if pb == nil || val.IsNil() {
w.Write([]byte("<nil>"))
return nil
}
var bw *bufio.Writer
ww, ok := w.(writer)
if !ok {
bw = bufio.NewWriter(w)
ww = bw
}
aw := &textWriter{
w: ww,
complete: true,
compact: compact,
}
if tm, ok := pb.(encoding.TextMarshaler); ok {
text, err := tm.MarshalText()
if err != nil {
return err
}
if _, err = aw.Write(text); err != nil {
return err
}
if bw != nil {
return bw.Flush()
}
return nil
}
// Dereference the received pointer so we don't have outer < and >.
v := reflect.Indirect(val)
if err := writeStruct(aw, v); err != nil {
return err
}
if bw != nil {
return bw.Flush()
}
return nil
}
// MarshalText writes a given protocol buffer in text format.
// The only errors returned are from w.
func MarshalText(w io.Writer, pb Message) error {
return marshalText(w, pb, false)
}
// MarshalTextString is the same as MarshalText, but returns the string directly.
func MarshalTextString(pb Message) string {
var buf bytes.Buffer
marshalText(&buf, pb, false)
return buf.String()
}
// CompactText writes a given protocol buffer in compact text format (one line).
func CompactText(w io.Writer, pb Message) error { return marshalText(w, pb, true) }
// CompactTextString is the same as CompactText, but returns the string directly.
func CompactTextString(pb Message) string {
var buf bytes.Buffer
marshalText(&buf, pb, true)
return buf.String()
}
// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
// http://github.com/gogo/protobuf/gogoproto
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"fmt"
"reflect"
)
func writeEnum(w *textWriter, v reflect.Value, props *Properties) error {
m, ok := enumStringMaps[props.Enum]
if !ok {
if err := writeAny(w, v, props); err != nil {
return err
}
}
key := int32(0)
if v.Kind() == reflect.Ptr {
key = int32(v.Elem().Int())
} else {
key = int32(v.Int())
}
s, ok := m[key]
if !ok {
if err := writeAny(w, v, props); err != nil {
return err
}
}
_, err := fmt.Fprint(w, s)
return err
}
// Extensions for Protocol Buffers to create more go like structures.
//
// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
// http://github.com/gogo/protobuf/gogoproto
//
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
// Functions for parsing the Text protocol buffer format.
// TODO: message sets.
import (
"encoding"
"errors"
"fmt"
"reflect"
"strconv"
"strings"
"unicode/utf8"
)
type ParseError struct {
Message string
Line int // 1-based line number
Offset int // 0-based byte offset from start of input
}
func (p *ParseError) Error() string {
if p.Line == 1 {
// show offset only for first line
return fmt.Sprintf("line 1.%d: %v", p.Offset, p.Message)
}
return fmt.Sprintf("line %d: %v", p.Line, p.Message)
}
type token struct {
value string
err *ParseError
line int // line number
offset int // byte number from start of input, not start of line
unquoted string // the unquoted version of value, if it was a quoted string
}
func (t *token) String() string {
if t.err == nil {
return fmt.Sprintf("%q (line=%d, offset=%d)", t.value, t.line, t.offset)
}
return fmt.Sprintf("parse error: %v", t.err)
}
type textParser struct {
s string // remaining input
done bool // whether the parsing is finished (success or error)
backed bool // whether back() was called
offset, line int
cur token
}
func newTextParser(s string) *textParser {
p := new(textParser)
p.s = s
p.line = 1
p.cur.line = 1
return p
}
func (p *textParser) errorf(format string, a ...interface{}) *ParseError {
pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset}
p.cur.err = pe
p.done = true
return pe
}
// Numbers and identifiers are matched by [-+._A-Za-z0-9]
func isIdentOrNumberChar(c byte) bool {
switch {
case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z':
return true
case '0' <= c && c <= '9':
return true
}
switch c {
case '-', '+', '.', '_':
return true
}
return false
}
func isWhitespace(c byte) bool {
switch c {
case ' ', '\t', '\n', '\r':
return true
}
return false
}
func (p *textParser) skipWhitespace() {
i := 0
for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') {
if p.s[i] == '#' {
// comment; skip to end of line or input
for i < len(p.s) && p.s[i] != '\n' {
i++
}
if i == len(p.s) {
break
}
}
if p.s[i] == '\n' {
p.line++
}
i++
}
p.offset += i
p.s = p.s[i:len(p.s)]
if len(p.s) == 0 {
p.done = true
}
}
func (p *textParser) advance() {
// Skip whitespace
p.skipWhitespace()
if p.done {
return
}
// Start of non-whitespace
p.cur.err = nil
p.cur.offset, p.cur.line = p.offset, p.line
p.cur.unquoted = ""
switch p.s[0] {
case '<', '>', '{', '}', ':', '[', ']', ';', ',':
// Single symbol
p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)]
case '"', '\'':
// Quoted string
i := 1
for i < len(p.s) && p.s[i] != p.s[0] && p.s[i] != '\n' {
if p.s[i] == '\\' && i+1 < len(p.s) {
// skip escaped char
i++
}
i++
}
if i >= len(p.s) || p.s[i] != p.s[0] {
p.errorf("unmatched quote")
return
}
unq, err := unquoteC(p.s[1:i], rune(p.s[0]))
if err != nil {
p.errorf("invalid quoted string %s: %v", p.s[0:i+1], err)
return
}
p.cur.value, p.s = p.s[0:i+1], p.s[i+1:len(p.s)]
p.cur.unquoted = unq
default:
i := 0
for i < len(p.s) && isIdentOrNumberChar(p.s[i]) {
i++
}
if i == 0 {
p.errorf("unexpected byte %#x", p.s[0])
return
}
p.cur.value, p.s = p.s[0:i], p.s[i:len(p.s)]
}
p.offset += len(p.cur.value)
}
var (
errBadUTF8 = errors.New("proto: bad UTF-8")
errBadHex = errors.New("proto: bad hexadecimal")
)
func unquoteC(s string, quote rune) (string, error) {
// This is based on C++'s tokenizer.cc.
// Despite its name, this is *not* parsing C syntax.
// For instance, "\0" is an invalid quoted string.
// Avoid allocation in trivial cases.
simple := true
for _, r := range s {
if r == '\\' || r == quote {
simple = false
break
}
}
if simple {
return s, nil
}
buf := make([]byte, 0, 3*len(s)/2)
for len(s) > 0 {
r, n := utf8.DecodeRuneInString(s)
if r == utf8.RuneError && n == 1 {
return "", errBadUTF8
}
s = s[n:]
if r != '\\' {
if r < utf8.RuneSelf {
buf = append(buf, byte(r))
} else {
buf = append(buf, string(r)...)
}
continue
}
ch, tail, err := unescape(s)
if err != nil {
return "", err
}
buf = append(buf, ch...)
s = tail
}
return string(buf), nil
}
func unescape(s string) (ch string, tail string, err error) {
r, n := utf8.DecodeRuneInString(s)
if r == utf8.RuneError && n == 1 {
return "", "", errBadUTF8
}
s = s[n:]
switch r {
case 'a':
return "\a", s, nil
case 'b':
return "\b", s, nil
case 'f':
return "\f", s, nil
case 'n':
return "\n", s, nil
case 'r':
return "\r", s, nil
case 't':
return "\t", s, nil
case 'v':
return "\v", s, nil
case '?':
return "?", s, nil // trigraph workaround
case '\'', '"', '\\':
return string(r), s, nil
case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X':
if len(s) < 2 {
return "", "", fmt.Errorf(`\%c requires 2 following digits`, r)
}
base := 8
ss := s[:2]
s = s[2:]
if r == 'x' || r == 'X' {
base = 16
} else {
ss = string(r) + ss
}
i, err := strconv.ParseUint(ss, base, 8)
if err != nil {
return "", "", err
}
return string([]byte{byte(i)}), s, nil
case 'u', 'U':
n := 4
if r == 'U' {
n = 8
}
if len(s) < n {
return "", "", fmt.Errorf(`\%c requires %d digits`, r, n)
}
bs := make([]byte, n/2)
for i := 0; i < n; i += 2 {
a, ok1 := unhex(s[i])
b, ok2 := unhex(s[i+1])
if !ok1 || !ok2 {
return "", "", errBadHex
}
bs[i/2] = a<<4 | b
}
s = s[n:]
return string(bs), s, nil
}
return "", "", fmt.Errorf(`unknown escape \%c`, r)
}
// Adapted from src/pkg/strconv/quote.go.
func unhex(b byte) (v byte, ok bool) {
switch {
case '0' <= b && b <= '9':
return b - '0', true
case 'a' <= b && b <= 'f':
return b - 'a' + 10, true
case 'A' <= b && b <= 'F':
return b - 'A' + 10, true
}
return 0, false
}
// Back off the parser by one token. Can only be done between calls to next().
// It makes the next advance() a no-op.
func (p *textParser) back() { p.backed = true }
// Advances the parser and returns the new current token.
func (p *textParser) next() *token {
if p.backed || p.done {
p.backed = false
return &p.cur
}
p.advance()
if p.done {
p.cur.value = ""
} else if len(p.cur.value) > 0 && p.cur.value[0] == '"' {
// Look for multiple quoted strings separated by whitespace,
// and concatenate them.
cat := p.cur
for {
p.skipWhitespace()
if p.done || p.s[0] != '"' {
break
}
p.advance()
if p.cur.err != nil {
return &p.cur
}
cat.value += " " + p.cur.value
cat.unquoted += p.cur.unquoted
}
p.done = false // parser may have seen EOF, but we want to return cat
p.cur = cat
}
return &p.cur
}
func (p *textParser) consumeToken(s string) error {
tok := p.next()
if tok.err != nil {
return tok.err
}
if tok.value != s {
p.back()
return p.errorf("expected %q, found %q", s, tok.value)
}
return nil
}
// Return a RequiredNotSetError indicating which required field was not set.
func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError {
st := sv.Type()
sprops := GetProperties(st)
for i := 0; i < st.NumField(); i++ {
if !isNil(sv.Field(i)) {
continue
}
props := sprops.Prop[i]
if props.Required {
return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)}
}
}
return &RequiredNotSetError{fmt.Sprintf("%v.<unknown field name>", st)} // should not happen
}
// Returns the index in the struct for the named field, as well as the parsed tag properties.
func structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) {
i, ok := sprops.decoderOrigNames[name]
if ok {
return i, sprops.Prop[i], true
}
return -1, nil, false
}
// Consume a ':' from the input stream (if the next token is a colon),
// returning an error if a colon is needed but not present.
func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseError {
tok := p.next()
if tok.err != nil {
return tok.err
}
if tok.value != ":" {
// Colon is optional when the field is a group or message.
needColon := true
switch props.Wire {
case "group":
needColon = false
case "bytes":
// A "bytes" field is either a message, a string, or a repeated field;
// those three become *T, *string and []T respectively, so we can check for
// this field being a pointer to a non-string.
if typ.Kind() == reflect.Ptr {
// *T or *string
if typ.Elem().Kind() == reflect.String {
break
}
} else if typ.Kind() == reflect.Slice {
// []T or []*T
if typ.Elem().Kind() != reflect.Ptr {
break
}
} else if typ.Kind() == reflect.String {
// The proto3 exception is for a string field,
// which requires a colon.
break
}
needColon = false
}
if needColon {
return p.errorf("expected ':', found %q", tok.value)
}
p.back()
}
return nil
}
func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
st := sv.Type()
sprops := GetProperties(st)
reqCount := sprops.reqCount
var reqFieldErr error
fieldSet := make(map[string]bool)
// A struct is a sequence of "name: value", terminated by one of
// '>' or '}', or the end of the input. A name may also be
// "[extension]".
for {
tok := p.next()
if tok.err != nil {
return tok.err
}
if tok.value == terminator {
break
}
if tok.value == "[" {
// Looks like an extension.
//
// TODO: Check whether we need to handle
// namespace rooted names (e.g. ".something.Foo").
tok = p.next()
if tok.err != nil {
return tok.err
}
var desc *ExtensionDesc
// This could be faster, but it's functional.
// TODO: Do something smarter than a linear scan.
for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) {
if d.Name == tok.value {
desc = d
break
}
}
if desc == nil {
return p.errorf("unrecognized extension %q", tok.value)
}
// Check the extension terminator.
tok = p.next()
if tok.err != nil {
return tok.err
}
if tok.value != "]" {
return p.errorf("unrecognized extension terminator %q", tok.value)
}
props := &Properties{}
props.Parse(desc.Tag)
typ := reflect.TypeOf(desc.ExtensionType)
if err := p.checkForColon(props, typ); err != nil {
return err
}
rep := desc.repeated()
// Read the extension structure, and set it in
// the value we're constructing.
var ext reflect.Value
if !rep {
ext = reflect.New(typ).Elem()
} else {
ext = reflect.New(typ.Elem()).Elem()
}
if err := p.readAny(ext, props); err != nil {
if _, ok := err.(*RequiredNotSetError); !ok {
return err
}
reqFieldErr = err
}
ep := sv.Addr().Interface().(extendableProto)
if !rep {
SetExtension(ep, desc, ext.Interface())
} else {
old, err := GetExtension(ep, desc)
var sl reflect.Value
if err == nil {
sl = reflect.ValueOf(old) // existing slice
} else {
sl = reflect.MakeSlice(typ, 0, 1)
}
sl = reflect.Append(sl, ext)
SetExtension(ep, desc, sl.Interface())
}
if err := p.consumeOptionalSeparator(); err != nil {
return err
}
continue
}
// This is a normal, non-extension field.
name := tok.value
var dst reflect.Value
fi, props, ok := structFieldByName(sprops, name)
if ok {
dst = sv.Field(fi)
} else if oop, ok := sprops.OneofTypes[name]; ok {
// It is a oneof.
props = oop.Prop
nv := reflect.New(oop.Type.Elem())
dst = nv.Elem().Field(0)
sv.Field(oop.Field).Set(nv)
}
if !dst.IsValid() {
return p.errorf("unknown field name %q in %v", name, st)
}
if dst.Kind() == reflect.Map {
// Consume any colon.
if err := p.checkForColon(props, dst.Type()); err != nil {
return err
}
// Construct the map if it doesn't already exist.
if dst.IsNil() {
dst.Set(reflect.MakeMap(dst.Type()))
}
key := reflect.New(dst.Type().Key()).Elem()
val := reflect.New(dst.Type().Elem()).Elem()
// The map entry should be this sequence of tokens:
// < key : KEY value : VALUE >
// Technically the "key" and "value" could come in any order,
// but in practice they won't.
tok := p.next()
var terminator string
switch tok.value {
case "<":
terminator = ">"
case "{":
terminator = "}"
default:
return p.errorf("expected '{' or '<', found %q", tok.value)
}
if err := p.consumeToken("key"); err != nil {
return err
}
if err := p.consumeToken(":"); err != nil {
return err
}
if err := p.readAny(key, props.mkeyprop); err != nil {
return err
}
if err := p.consumeOptionalSeparator(); err != nil {
return err
}
if err := p.consumeToken("value"); err != nil {
return err
}
if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil {
return err
}
if err := p.readAny(val, props.mvalprop); err != nil {
return err
}
if err := p.consumeOptionalSeparator(); err != nil {
return err
}
if err := p.consumeToken(terminator); err != nil {
return err
}
dst.SetMapIndex(key, val)
continue
}
// Check that it's not already set if it's not a repeated field.
if !props.Repeated && fieldSet[name] {
return p.errorf("non-repeated field %q was repeated", name)
}
if err := p.checkForColon(props, dst.Type()); err != nil {
return err
}
// Parse into the field.
fieldSet[name] = true
if err := p.readAny(dst, props); err != nil {
if _, ok := err.(*RequiredNotSetError); !ok {
return err
}
reqFieldErr = err
} else if props.Required {
reqCount--
}
if err := p.consumeOptionalSeparator(); err != nil {
return err
}
}
if reqCount > 0 {
return p.missingRequiredFieldError(sv)
}
return reqFieldErr
}
// consumeOptionalSeparator consumes an optional semicolon or comma.
// It is used in readStruct to provide backward compatibility.
func (p *textParser) consumeOptionalSeparator() error {
tok := p.next()
if tok.err != nil {
return tok.err
}
if tok.value != ";" && tok.value != "," {
p.back()
}
return nil
}
func (p *textParser) readAny(v reflect.Value, props *Properties) error {
tok := p.next()
if tok.err != nil {
return tok.err
}
if tok.value == "" {
return p.errorf("unexpected EOF")
}
if len(props.CustomType) > 0 {
if props.Repeated {
t := reflect.TypeOf(v.Interface())
if t.Kind() == reflect.Slice {
tc := reflect.TypeOf(new(Marshaler))
ok := t.Elem().Implements(tc.Elem())
if ok {
fv := v
flen := fv.Len()
if flen == fv.Cap() {
nav := reflect.MakeSlice(v.Type(), flen, 2*flen+1)
reflect.Copy(nav, fv)
fv.Set(nav)
}
fv.SetLen(flen + 1)
// Read one.
p.back()
return p.readAny(fv.Index(flen), props)
}
}
}
if reflect.TypeOf(v.Interface()).Kind() == reflect.Ptr {
custom := reflect.New(props.ctype.Elem()).Interface().(Unmarshaler)
err := custom.Unmarshal([]byte(tok.unquoted))
if err != nil {
return p.errorf("%v %v: %v", err, v.Type(), tok.value)
}
v.Set(reflect.ValueOf(custom))
} else {
custom := reflect.New(reflect.TypeOf(v.Interface())).Interface().(Unmarshaler)
err := custom.Unmarshal([]byte(tok.unquoted))
if err != nil {
return p.errorf("%v %v: %v", err, v.Type(), tok.value)
}
v.Set(reflect.Indirect(reflect.ValueOf(custom)))
}
return nil
}
switch fv := v; fv.Kind() {
case reflect.Slice:
at := v.Type()
if at.Elem().Kind() == reflect.Uint8 {
// Special case for []byte
if tok.value[0] != '"' && tok.value[0] != '\'' {
// Deliberately written out here, as the error after
// this switch statement would write "invalid []byte: ...",
// which is not as user-friendly.
return p.errorf("invalid string: %v", tok.value)
}
bytes := []byte(tok.unquoted)
fv.Set(reflect.ValueOf(bytes))
return nil
}
// Repeated field. May already exist.
flen := fv.Len()
if flen == fv.Cap() {
nav := reflect.MakeSlice(at, flen, 2*flen+1)
reflect.Copy(nav, fv)
fv.Set(nav)
}
fv.SetLen(flen + 1)
// Read one.
p.back()
return p.readAny(fv.Index(flen), props)
case reflect.Bool:
// Either "true", "false", 1 or 0.
switch tok.value {
case "true", "1":
fv.SetBool(true)
return nil
case "false", "0":
fv.SetBool(false)
return nil
}
case reflect.Float32, reflect.Float64:
v := tok.value
// Ignore 'f' for compatibility with output generated by C++, but don't
// remove 'f' when the value is "-inf" or "inf".
if strings.HasSuffix(v, "f") && tok.value != "-inf" && tok.value != "inf" {
v = v[:len(v)-1]
}
if f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil {
fv.SetFloat(f)
return nil
}
case reflect.Int32:
if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil {
fv.SetInt(x)
return nil
}
if len(props.Enum) == 0 {
break
}
m, ok := enumValueMaps[props.Enum]
if !ok {
break
}
x, ok := m[tok.value]
if !ok {
break
}
fv.SetInt(int64(x))
return nil
case reflect.Int64:
if x, err := strconv.ParseInt(tok.value, 0, 64); err == nil {
fv.SetInt(x)
return nil
}
case reflect.Ptr:
// A basic field (indirected through pointer), or a repeated message/group
p.back()
fv.Set(reflect.New(fv.Type().Elem()))
return p.readAny(fv.Elem(), props)
case reflect.String:
if tok.value[0] == '"' || tok.value[0] == '\'' {
fv.SetString(tok.unquoted)
return nil
}
case reflect.Struct:
var terminator string
switch tok.value {
case "{":
terminator = "}"
case "<":
terminator = ">"
default:
return p.errorf("expected '{' or '<', found %q", tok.value)
}
// TODO: Handle nested messages which implement encoding.TextUnmarshaler.
return p.readStruct(fv, terminator)
case reflect.Uint32:
if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
fv.SetUint(uint64(x))
return nil
}
case reflect.Uint64:
if x, err := strconv.ParseUint(tok.value, 0, 64); err == nil {
fv.SetUint(x)
return nil
}
}
return p.errorf("invalid %v: %v", v.Type(), tok.value)
}
// UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb
// before starting to unmarshal, so any existing data in pb is always removed.
// If a required field is not set and no other error occurs,
// UnmarshalText returns *RequiredNotSetError.
func UnmarshalText(s string, pb Message) error {
if um, ok := pb.(encoding.TextUnmarshaler); ok {
err := um.UnmarshalText([]byte(s))
return err
}
pb.Reset()
v := reflect.ValueOf(pb)
if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil {
return pe
}
return nil
}
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto_test
import (
"math"
"reflect"
"testing"
. "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto"
proto3pb "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto/proto3_proto"
. "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto/testdata"
)
type UnmarshalTextTest struct {
in string
err string // if "", no error expected
out *MyMessage
}
func buildExtStructTest(text string) UnmarshalTextTest {
msg := &MyMessage{
Count: Int32(42),
}
SetExtension(msg, E_Ext_More, &Ext{
Data: String("Hello, world!"),
})
return UnmarshalTextTest{in: text, out: msg}
}
func buildExtDataTest(text string) UnmarshalTextTest {
msg := &MyMessage{
Count: Int32(42),
}
SetExtension(msg, E_Ext_Text, String("Hello, world!"))
SetExtension(msg, E_Ext_Number, Int32(1729))
return UnmarshalTextTest{in: text, out: msg}
}
func buildExtRepStringTest(text string) UnmarshalTextTest {
msg := &MyMessage{
Count: Int32(42),
}
if err := SetExtension(msg, E_Greeting, []string{"bula", "hola"}); err != nil {
panic(err)
}
return UnmarshalTextTest{in: text, out: msg}
}
var unMarshalTextTests = []UnmarshalTextTest{
// Basic
{
in: " count:42\n name:\"Dave\" ",
out: &MyMessage{
Count: Int32(42),
Name: String("Dave"),
},
},
// Empty quoted string
{
in: `count:42 name:""`,
out: &MyMessage{
Count: Int32(42),
Name: String(""),
},
},
// Quoted string concatenation
{
in: `count:42 name: "My name is "` + "\n" + `"elsewhere"`,
out: &MyMessage{
Count: Int32(42),
Name: String("My name is elsewhere"),
},
},
// Quoted string with escaped apostrophe
{
in: `count:42 name: "HOLIDAY - New Year\'s Day"`,
out: &MyMessage{
Count: Int32(42),
Name: String("HOLIDAY - New Year's Day"),
},
},
// Quoted string with single quote
{
in: `count:42 name: 'Roger "The Ramster" Ramjet'`,
out: &MyMessage{
Count: Int32(42),
Name: String(`Roger "The Ramster" Ramjet`),
},
},
// Quoted string with all the accepted special characters from the C++ test
{
in: `count:42 name: ` + "\"\\\"A string with \\' characters \\n and \\r newlines and \\t tabs and \\001 slashes \\\\ and multiple spaces\"",
out: &MyMessage{
Count: Int32(42),
Name: String("\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\ and multiple spaces"),
},
},
// Quoted string with quoted backslash
{
in: `count:42 name: "\\'xyz"`,
out: &MyMessage{
Count: Int32(42),
Name: String(`\'xyz`),
},
},
// Quoted string with UTF-8 bytes.
{
in: "count:42 name: '\303\277\302\201\xAB'",
out: &MyMessage{
Count: Int32(42),
Name: String("\303\277\302\201\xAB"),
},
},
// Bad quoted string
{
in: `inner: < host: "\0" >` + "\n",
err: `line 1.15: invalid quoted string "\0": \0 requires 2 following digits`,
},
// Number too large for int64
{
in: "count: 1 others { key: 123456789012345678901 }",
err: "line 1.23: invalid int64: 123456789012345678901",
},
// Number too large for int32
{
in: "count: 1234567890123",
err: "line 1.7: invalid int32: 1234567890123",
},
// Number in hexadecimal
{
in: "count: 0x2beef",
out: &MyMessage{
Count: Int32(0x2beef),
},
},
// Number in octal
{
in: "count: 024601",
out: &MyMessage{
Count: Int32(024601),
},
},
// Floating point number with "f" suffix
{
in: "count: 4 others:< weight: 17.0f >",
out: &MyMessage{
Count: Int32(4),
Others: []*OtherMessage{
{
Weight: Float32(17),
},
},
},
},
// Floating point positive infinity
{
in: "count: 4 bigfloat: inf",
out: &MyMessage{
Count: Int32(4),
Bigfloat: Float64(math.Inf(1)),
},
},
// Floating point negative infinity
{
in: "count: 4 bigfloat: -inf",
out: &MyMessage{
Count: Int32(4),
Bigfloat: Float64(math.Inf(-1)),
},
},
// Number too large for float32
{
in: "others:< weight: 12345678901234567890123456789012345678901234567890 >",
err: "line 1.17: invalid float32: 12345678901234567890123456789012345678901234567890",
},
// Number posing as a quoted string
{
in: `inner: < host: 12 >` + "\n",
err: `line 1.15: invalid string: 12`,
},
// Quoted string posing as int32
{
in: `count: "12"`,
err: `line 1.7: invalid int32: "12"`,
},
// Quoted string posing a float32
{
in: `others:< weight: "17.4" >`,
err: `line 1.17: invalid float32: "17.4"`,
},
// Enum
{
in: `count:42 bikeshed: BLUE`,
out: &MyMessage{
Count: Int32(42),
Bikeshed: MyMessage_BLUE.Enum(),
},
},
// Repeated field
{
in: `count:42 pet: "horsey" pet:"bunny"`,
out: &MyMessage{
Count: Int32(42),
Pet: []string{"horsey", "bunny"},
},
},
// Repeated message with/without colon and <>/{}
{
in: `count:42 others:{} others{} others:<> others:{}`,
out: &MyMessage{
Count: Int32(42),
Others: []*OtherMessage{
{},
{},
{},
{},
},
},
},
// Missing colon for inner message
{
in: `count:42 inner < host: "cauchy.syd" >`,
out: &MyMessage{
Count: Int32(42),
Inner: &InnerMessage{
Host: String("cauchy.syd"),
},
},
},
// Missing colon for string field
{
in: `name "Dave"`,
err: `line 1.5: expected ':', found "\"Dave\""`,
},
// Missing colon for int32 field
{
in: `count 42`,
err: `line 1.6: expected ':', found "42"`,
},
// Missing required field
{
in: `name: "Pawel"`,
err: `proto: required field "testdata.MyMessage.count" not set`,
out: &MyMessage{
Name: String("Pawel"),
},
},
// Repeated non-repeated field
{
in: `name: "Rob" name: "Russ"`,
err: `line 1.12: non-repeated field "name" was repeated`,
},
// Group
{
in: `count: 17 SomeGroup { group_field: 12 }`,
out: &MyMessage{
Count: Int32(17),
Somegroup: &MyMessage_SomeGroup{
GroupField: Int32(12),
},
},
},
// Semicolon between fields
{
in: `count:3;name:"Calvin"`,
out: &MyMessage{
Count: Int32(3),
Name: String("Calvin"),
},
},
// Comma between fields
{
in: `count:4,name:"Ezekiel"`,
out: &MyMessage{
Count: Int32(4),
Name: String("Ezekiel"),
},
},
// Extension
buildExtStructTest(`count: 42 [testdata.Ext.more]:<data:"Hello, world!" >`),
buildExtStructTest(`count: 42 [testdata.Ext.more] {data:"Hello, world!"}`),
buildExtDataTest(`count: 42 [testdata.Ext.text]:"Hello, world!" [testdata.Ext.number]:1729`),
buildExtRepStringTest(`count: 42 [testdata.greeting]:"bula" [testdata.greeting]:"hola"`),
// Big all-in-one
{
in: "count:42 # Meaning\n" +
`name:"Dave" ` +
`quote:"\"I didn't want to go.\"" ` +
`pet:"bunny" ` +
`pet:"kitty" ` +
`pet:"horsey" ` +
`inner:<` +
` host:"footrest.syd" ` +
` port:7001 ` +
` connected:true ` +
`> ` +
`others:<` +
` key:3735928559 ` +
` value:"\x01A\a\f" ` +
`> ` +
`others:<` +
" weight:58.9 # Atomic weight of Co\n" +
` inner:<` +
` host:"lesha.mtv" ` +
` port:8002 ` +
` >` +
`>`,
out: &MyMessage{
Count: Int32(42),
Name: String("Dave"),
Quote: String(`"I didn't want to go."`),
Pet: []string{"bunny", "kitty", "horsey"},
Inner: &InnerMessage{
Host: String("footrest.syd"),
Port: Int32(7001),
Connected: Bool(true),
},
Others: []*OtherMessage{
{
Key: Int64(3735928559),
Value: []byte{0x1, 'A', '\a', '\f'},
},
{
Weight: Float32(58.9),
Inner: &InnerMessage{
Host: String("lesha.mtv"),
Port: Int32(8002),
},
},
},
},
},
}
func TestUnmarshalText(t *testing.T) {
for i, test := range unMarshalTextTests {
pb := new(MyMessage)
err := UnmarshalText(test.in, pb)
if test.err == "" {
// We don't expect failure.
if err != nil {
t.Errorf("Test %d: Unexpected error: %v", i, err)
} else if !reflect.DeepEqual(pb, test.out) {
t.Errorf("Test %d: Incorrect populated \nHave: %v\nWant: %v",
i, pb, test.out)
}
} else {
// We do expect failure.
if err == nil {
t.Errorf("Test %d: Didn't get expected error: %v", i, test.err)
} else if err.Error() != test.err {
t.Errorf("Test %d: Incorrect error.\nHave: %v\nWant: %v",
i, err.Error(), test.err)
} else if _, ok := err.(*RequiredNotSetError); ok && test.out != nil && !reflect.DeepEqual(pb, test.out) {
t.Errorf("Test %d: Incorrect populated \nHave: %v\nWant: %v",
i, pb, test.out)
}
}
}
}
func TestUnmarshalTextCustomMessage(t *testing.T) {
msg := &textMessage{}
if err := UnmarshalText("custom", msg); err != nil {
t.Errorf("Unexpected error from custom unmarshal: %v", err)
}
if UnmarshalText("not custom", msg) == nil {
t.Errorf("Didn't get expected error from custom unmarshal")
}
}
// Regression test; this caused a panic.
func TestRepeatedEnum(t *testing.T) {
pb := new(RepeatedEnum)
if err := UnmarshalText("color: RED", pb); err != nil {
t.Fatal(err)
}
exp := &RepeatedEnum{
Color: []RepeatedEnum_Color{RepeatedEnum_RED},
}
if !Equal(pb, exp) {
t.Errorf("Incorrect populated \nHave: %v\nWant: %v", pb, exp)
}
}
func TestProto3TextParsing(t *testing.T) {
m := new(proto3pb.Message)
const in = `name: "Wallace" true_scotsman: true`
want := &proto3pb.Message{
Name: "Wallace",
TrueScotsman: true,
}
if err := UnmarshalText(in, m); err != nil {
t.Fatal(err)
}
if !Equal(m, want) {
t.Errorf("\n got %v\nwant %v", m, want)
}
}
func TestMapParsing(t *testing.T) {
m := new(MessageWithMap)
const in = `name_mapping:<key:1234 value:"Feist"> name_mapping:<key:1 value:"Beatles">` +
`msg_mapping:<key:-4, value:<f: 2.0>,>` + // separating commas are okay
`msg_mapping<key:-2 value<f: 4.0>>` + // no colon after "value"
`byte_mapping:<key:true value:"so be it">`
want := &MessageWithMap{
NameMapping: map[int32]string{
1: "Beatles",
1234: "Feist",
},
MsgMapping: map[int64]*FloatingPoint{
-4: {F: Float64(2.0)},
-2: {F: Float64(4.0)},
},
ByteMapping: map[bool][]byte{
true: []byte("so be it"),
},
}
if err := UnmarshalText(in, m); err != nil {
t.Fatal(err)
}
if !Equal(m, want) {
t.Errorf("\n got %v\nwant %v", m, want)
}
}
func TestOneofParsing(t *testing.T) {
const in = `name:"Shrek"`
m := new(Communique)
want := &Communique{Union: &Communique_Name{"Shrek"}}
if err := UnmarshalText(in, m); err != nil {
t.Fatal(err)
}
if !Equal(m, want) {
t.Errorf("\n got %v\nwant %v", m, want)
}
}
var benchInput string
func init() {
benchInput = "count: 4\n"
for i := 0; i < 1000; i++ {
benchInput += "pet: \"fido\"\n"
}
// Check it is valid input.
pb := new(MyMessage)
err := UnmarshalText(benchInput, pb)
if err != nil {
panic("Bad benchmark input: " + err.Error())
}
}
func BenchmarkUnmarshalText(b *testing.B) {
pb := new(MyMessage)
for i := 0; i < b.N; i++ {
UnmarshalText(benchInput, pb)
}
b.SetBytes(int64(len(benchInput)))
}
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto_test
import (
"bytes"
"errors"
"io/ioutil"
"math"
"strings"
"testing"
"QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto"
proto3pb "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto/proto3_proto"
pb "QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/proto/testdata"
)
// textMessage implements the methods that allow it to marshal and unmarshal
// itself as text.
type textMessage struct {
}
func (*textMessage) MarshalText() ([]byte, error) {
return []byte("custom"), nil
}
func (*textMessage) UnmarshalText(bytes []byte) error {
if string(bytes) != "custom" {
return errors.New("expected 'custom'")
}
return nil
}
func (*textMessage) Reset() {}
func (*textMessage) String() string { return "" }
func (*textMessage) ProtoMessage() {}
func newTestMessage() *pb.MyMessage {
msg := &pb.MyMessage{
Count: proto.Int32(42),
Name: proto.String("Dave"),
Quote: proto.String(`"I didn't want to go."`),
Pet: []string{"bunny", "kitty", "horsey"},
Inner: &pb.InnerMessage{
Host: proto.String("footrest.syd"),
Port: proto.Int32(7001),
Connected: proto.Bool(true),
},
Others: []*pb.OtherMessage{
{
Key: proto.Int64(0xdeadbeef),
Value: []byte{1, 65, 7, 12},
},
{
Weight: proto.Float32(6.022),
Inner: &pb.InnerMessage{
Host: proto.String("lesha.mtv"),
Port: proto.Int32(8002),
},
},
},
Bikeshed: pb.MyMessage_BLUE.Enum(),
Somegroup: &pb.MyMessage_SomeGroup{
GroupField: proto.Int32(8),
},
// One normally wouldn't do this.
// This is an undeclared tag 13, as a varint (wire type 0) with value 4.
XXX_unrecognized: []byte{13<<3 | 0, 4},
}
ext := &pb.Ext{
Data: proto.String("Big gobs for big rats"),
}
if err := proto.SetExtension(msg, pb.E_Ext_More, ext); err != nil {
panic(err)
}
greetings := []string{"adg", "easy", "cow"}
if err := proto.SetExtension(msg, pb.E_Greeting, greetings); err != nil {
panic(err)
}
// Add an unknown extension. We marshal a pb.Ext, and fake the ID.
b, err := proto.Marshal(&pb.Ext{Data: proto.String("3G skiing")})
if err != nil {
panic(err)
}
b = append(proto.EncodeVarint(201<<3|proto.WireBytes), b...)
proto.SetRawExtension(msg, 201, b)
// Extensions can be plain fields, too, so let's test that.
b = append(proto.EncodeVarint(202<<3|proto.WireVarint), 19)
proto.SetRawExtension(msg, 202, b)
return msg
}
const text = `count: 42
name: "Dave"
quote: "\"I didn't want to go.\""
pet: "bunny"
pet: "kitty"
pet: "horsey"
inner: <
host: "footrest.syd"
port: 7001
connected: true
>
others: <
key: 3735928559
value: "\001A\007\014"
>
others: <
weight: 6.022
inner: <
host: "lesha.mtv"
port: 8002
>
>
bikeshed: BLUE
SomeGroup {
group_field: 8
}
/* 2 unknown bytes */
13: 4
[testdata.Ext.more]: <
data: "Big gobs for big rats"
>
[testdata.greeting]: "adg"
[testdata.greeting]: "easy"
[testdata.greeting]: "cow"
/* 13 unknown bytes */
201: "\t3G skiing"
/* 3 unknown bytes */
202: 19
`
func TestMarshalText(t *testing.T) {
buf := new(bytes.Buffer)
if err := proto.MarshalText(buf, newTestMessage()); err != nil {
t.Fatalf("proto.MarshalText: %v", err)
}
s := buf.String()
if s != text {
t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v===\n", s, text)
}
}
func TestMarshalTextCustomMessage(t *testing.T) {
buf := new(bytes.Buffer)
if err := proto.MarshalText(buf, &textMessage{}); err != nil {
t.Fatalf("proto.MarshalText: %v", err)
}
s := buf.String()
if s != "custom" {
t.Errorf("Got %q, expected %q", s, "custom")
}
}
func TestMarshalTextNil(t *testing.T) {
want := "<nil>"
tests := []proto.Message{nil, (*pb.MyMessage)(nil)}
for i, test := range tests {
buf := new(bytes.Buffer)
if err := proto.MarshalText(buf, test); err != nil {
t.Fatal(err)
}
if got := buf.String(); got != want {
t.Errorf("%d: got %q want %q", i, got, want)
}
}
}
func TestMarshalTextUnknownEnum(t *testing.T) {
// The Color enum only specifies values 0-2.
m := &pb.MyMessage{Bikeshed: pb.MyMessage_Color(3).Enum()}
got := m.String()
const want = `bikeshed:3 `
if got != want {
t.Errorf("\n got %q\nwant %q", got, want)
}
}
func TestTextOneof(t *testing.T) {
tests := []struct {
m proto.Message
want string
}{
// zero message
{&pb.Communique{}, ``},
// scalar field
{&pb.Communique{Union: &pb.Communique_Number{Number: 4}}, `number:4`},
// message field
{&pb.Communique{Union: &pb.Communique_Msg{
Msg: &pb.Strings{StringField: proto.String("why hello!")},
}}, `msg:<string_field:"why hello!" >`},
// bad oneof (should not panic)
{&pb.Communique{Union: &pb.Communique_Msg{Msg: nil}}, `msg:/* nil */`},
}
for _, test := range tests {
got := strings.TrimSpace(test.m.String())
if got != test.want {
t.Errorf("\n got %s\nwant %s", got, test.want)
}
}
}
func BenchmarkMarshalTextBuffered(b *testing.B) {
buf := new(bytes.Buffer)
m := newTestMessage()
for i := 0; i < b.N; i++ {
buf.Reset()
proto.MarshalText(buf, m)
}
}
func BenchmarkMarshalTextUnbuffered(b *testing.B) {
w := ioutil.Discard
m := newTestMessage()
for i := 0; i < b.N; i++ {
proto.MarshalText(w, m)
}
}
func compact(src string) string {
// s/[ \n]+/ /g; s/ $//;
dst := make([]byte, len(src))
space, comment := false, false
j := 0
for i := 0; i < len(src); i++ {
if strings.HasPrefix(src[i:], "/*") {
comment = true
i++
continue
}
if comment && strings.HasPrefix(src[i:], "*/") {
comment = false
i++
continue
}
if comment {
continue
}
c := src[i]
if c == ' ' || c == '\n' {
space = true
continue
}
if j > 0 && (dst[j-1] == ':' || dst[j-1] == '<' || dst[j-1] == '{') {
space = false
}
if c == '{' {
space = false
}
if space {
dst[j] = ' '
j++
space = false
}
dst[j] = c
j++
}
if space {
dst[j] = ' '
j++
}
return string(dst[0:j])
}
var compactText = compact(text)
func TestCompactText(t *testing.T) {
s := proto.CompactTextString(newTestMessage())
if s != compactText {
t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v\n===\n", s, compactText)
}
}
func TestStringEscaping(t *testing.T) {
testCases := []struct {
in *pb.Strings
out string
}{
{
// Test data from C++ test (TextFormatTest.StringEscape).
// Single divergence: we don't escape apostrophes.
&pb.Strings{StringField: proto.String("\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\ and multiple spaces")},
"string_field: \"\\\"A string with ' characters \\n and \\r newlines and \\t tabs and \\001 slashes \\\\ and multiple spaces\"\n",
},
{
// Test data from the same C++ test.
&pb.Strings{StringField: proto.String("\350\260\267\346\255\214")},
"string_field: \"\\350\\260\\267\\346\\255\\214\"\n",
},
{
// Some UTF-8.
&pb.Strings{StringField: proto.String("\x00\x01\xff\x81")},
`string_field: "\000\001\377\201"` + "\n",
},
}
for i, tc := range testCases {
var buf bytes.Buffer
if err := proto.MarshalText(&buf, tc.in); err != nil {
t.Errorf("proto.MarsalText: %v", err)
continue
}
s := buf.String()
if s != tc.out {
t.Errorf("#%d: Got:\n%s\nExpected:\n%s\n", i, s, tc.out)
continue
}
// Check round-trip.
pb := new(pb.Strings)
if err := proto.UnmarshalText(s, pb); err != nil {
t.Errorf("#%d: UnmarshalText: %v", i, err)
continue
}
if !proto.Equal(pb, tc.in) {
t.Errorf("#%d: Round-trip failed:\nstart: %v\n end: %v", i, tc.in, pb)
}
}
}
// A limitedWriter accepts some output before it fails.
// This is a proxy for something like a nearly-full or imminently-failing disk,
// or a network connection that is about to die.
type limitedWriter struct {
b bytes.Buffer
limit int
}
var outOfSpace = errors.New("proto: insufficient space")
func (w *limitedWriter) Write(p []byte) (n int, err error) {
var avail = w.limit - w.b.Len()
if avail <= 0 {
return 0, outOfSpace
}
if len(p) <= avail {
return w.b.Write(p)
}
n, _ = w.b.Write(p[:avail])
return n, outOfSpace
}
func TestMarshalTextFailing(t *testing.T) {
// Try lots of different sizes to exercise more error code-paths.
for lim := 0; lim < len(text); lim++ {
buf := new(limitedWriter)
buf.limit = lim
err := proto.MarshalText(buf, newTestMessage())
// We expect a certain error, but also some partial results in the buffer.
if err != outOfSpace {
t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v===\n", err, outOfSpace)
}
s := buf.b.String()
x := text[:buf.limit]
if s != x {
t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v===\n", s, x)
}
}
}
func TestFloats(t *testing.T) {
tests := []struct {
f float64
want string
}{
{0, "0"},
{4.7, "4.7"},
{math.Inf(1), "inf"},
{math.Inf(-1), "-inf"},
{math.NaN(), "nan"},
}
for _, test := range tests {
msg := &pb.FloatingPoint{F: &test.f}
got := strings.TrimSpace(msg.String())
want := `f:` + test.want
if got != want {
t.Errorf("f=%f: got %q, want %q", test.f, got, want)
}
}
}
func TestRepeatedNilText(t *testing.T) {
m := &pb.MessageList{
Message: []*pb.MessageList_Message{
nil,
{
Name: proto.String("Horse"),
},
nil,
},
}
want := `Message <nil>
Message {
name: "Horse"
}
Message <nil>
`
if s := proto.MarshalTextString(m); s != want {
t.Errorf(" got: %s\nwant: %s", s, want)
}
}
func TestProto3Text(t *testing.T) {
tests := []struct {
m proto.Message
want string
}{
// zero message
{&proto3pb.Message{}, ``},
// zero message except for an empty byte slice
{&proto3pb.Message{Data: []byte{}}, ``},
// trivial case
{&proto3pb.Message{Name: "Rob", HeightInCm: 175}, `name:"Rob" height_in_cm:175`},
// empty map
{&pb.MessageWithMap{}, ``},
// non-empty map; map format is the same as a repeated struct,
// and they are sorted by key (numerically for numeric keys).
{
&pb.MessageWithMap{NameMapping: map[int32]string{
-1: "Negatory",
7: "Lucky",
1234: "Feist",
6345789: "Otis",
}},
`name_mapping:<key:-1 value:"Negatory" > ` +
`name_mapping:<key:7 value:"Lucky" > ` +
`name_mapping:<key:1234 value:"Feist" > ` +
`name_mapping:<key:6345789 value:"Otis" >`,
},
// map with nil value; not well-defined, but we shouldn't crash
{
&pb.MessageWithMap{MsgMapping: map[int64]*pb.FloatingPoint{7: nil}},
`msg_mapping:<key:7 >`,
},
}
for _, test := range tests {
got := strings.TrimSpace(test.m.String())
if got != test.want {
t.Errorf("\n got %s\nwant %s", got, test.want)
}
}
}
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
//
// WARNING: The plugin interface is currently EXPERIMENTAL and is subject to
// change.
//
// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is
// just a program that reads a CodeGeneratorRequest from stdin and writes a
// CodeGeneratorResponse to stdout.
//
// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead
// of dealing with the raw protocol defined here.
//
// A plugin executable needs only to be placed somewhere in the path. The
// plugin should be named "protoc-gen-$NAME", and will then be used when the
// flag "--${NAME}_out" is passed to protoc.
syntax = "proto2";
package google.protobuf.compiler;
option java_package = "com.google.protobuf.compiler";
option java_outer_classname = "PluginProtos";
import "google/protobuf/descriptor.proto";
// An encoded CodeGeneratorRequest is written to the plugin's stdin.
message CodeGeneratorRequest {
// The .proto files that were explicitly listed on the command-line. The
// code generator should generate code only for these files. Each file's
// descriptor will be included in proto_file, below.
repeated string file_to_generate = 1;
// The generator parameter passed on the command-line.
optional string parameter = 2;
// FileDescriptorProtos for all files in files_to_generate and everything
// they import. The files will appear in topological order, so each file
// appears before any file that imports it.
//
// protoc guarantees that all proto_files will be written after
// the fields above, even though this is not technically guaranteed by the
// protobuf wire format. This theoretically could allow a plugin to stream
// in the FileDescriptorProtos and handle them one by one rather than read
// the entire set into memory at once. However, as of this writing, this
// is not similarly optimized on protoc's end -- it will store all fields in
// memory at once before sending them to the plugin.
repeated FileDescriptorProto proto_file = 15;
}
// The plugin writes an encoded CodeGeneratorResponse to stdout.
message CodeGeneratorResponse {
// Error message. If non-empty, code generation failed. The plugin process
// should exit with status code zero even if it reports an error in this way.
//
// This should be used to indicate errors in .proto files which prevent the
// code generator from generating correct code. Errors which indicate a
// problem in protoc itself -- such as the input CodeGeneratorRequest being
// unparseable -- should be reported by writing a message to stderr and
// exiting with a non-zero status code.
optional string error = 1;
// Represents a single generated file.
message File {
// The file name, relative to the output directory. The name must not
// contain "." or ".." components and must be relative, not be absolute (so,
// the file cannot lie outside the output directory). "/" must be used as
// the path separator, not "\".
//
// If the name is omitted, the content will be appended to the previous
// file. This allows the generator to break large files into small chunks,
// and allows the generated text to be streamed back to protoc so that large
// files need not reside completely in memory at one time. Note that as of
// this writing protoc does not optimize for this -- it will read the entire
// CodeGeneratorResponse before writing files to disk.
optional string name = 1;
// If non-empty, indicates that the named file should already exist, and the
// content here is to be inserted into that file at a defined insertion
// point. This feature allows a code generator to extend the output
// produced by another code generator. The original generator may provide
// insertion points by placing special annotations in the file that look
// like:
// @@protoc_insertion_point(NAME)
// The annotation can have arbitrary text before and after it on the line,
// which allows it to be placed in a comment. NAME should be replaced with
// an identifier naming the point -- this is what other generators will use
// as the insertion_point. Code inserted at this point will be placed
// immediately above the line containing the insertion point (thus multiple
// insertions to the same point will come out in the order they were added).
// The double-@ is intended to make it unlikely that the generated code
// could contain things that look like insertion points by accident.
//
// For example, the C++ code generator places the following line in the
// .pb.h files that it generates:
// // @@protoc_insertion_point(namespace_scope)
// This line appears within the scope of the file's package namespace, but
// outside of any particular class. Another plugin can then specify the
// insertion_point "namespace_scope" to generate additional classes or
// other declarations that should be placed in this scope.
//
// Note that if the line containing the insertion point begins with
// whitespace, the same whitespace will be added to every line of the
// inserted text. This is useful for languages like Python, where
// indentation matters. In these languages, the insertion point comment
// should be indented the same amount as any inserted code will need to be
// in order to work correctly in that context.
//
// The code generator that generates the initial file and the one which
// inserts into it must both run as part of a single invocation of protoc.
// Code generators are executed in the order in which they appear on the
// command line.
//
// If |insertion_point| is present, |name| must also be present.
optional string insertion_point = 2;
// The file contents.
optional string content = 15;
}
repeated File file = 15;
}
\ No newline at end of file
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// The messages in this file describe the definitions found in .proto files.
// A valid .proto file can be translated directly to a FileDescriptorProto
// without any other information (e.g. without reading its imports).
syntax = "proto2";
package google.protobuf;
option java_package = "com.google.protobuf";
option java_outer_classname = "DescriptorProtos";
// descriptor.proto must be optimized for speed because reflection-based
// algorithms don't work during bootstrapping.
option optimize_for = SPEED;
// The protocol compiler can output a FileDescriptorSet containing the .proto
// files it parses.
message FileDescriptorSet {
repeated FileDescriptorProto file = 1;
}
// Describes a complete .proto file.
message FileDescriptorProto {
optional string name = 1; // file name, relative to root of source tree
optional string package = 2; // e.g. "foo", "foo.bar", etc.
// Names of files imported by this file.
repeated string dependency = 3;
// Indexes of the public imported files in the dependency list above.
repeated int32 public_dependency = 10;
// Indexes of the weak imported files in the dependency list.
// For Google-internal migration only. Do not use.
repeated int32 weak_dependency = 11;
// All top-level definitions in this file.
repeated DescriptorProto message_type = 4;
repeated EnumDescriptorProto enum_type = 5;
repeated ServiceDescriptorProto service = 6;
repeated FieldDescriptorProto extension = 7;
optional FileOptions options = 8;
// This field contains optional information about the original source code.
// You may safely remove this entire field without harming runtime
// functionality of the descriptors -- the information is needed only by
// development tools.
optional SourceCodeInfo source_code_info = 9;
// The syntax of the proto file.
// The supported values are "proto2" and "proto3".
optional string syntax = 12;
}
// Describes a message type.
message DescriptorProto {
optional string name = 1;
repeated FieldDescriptorProto field = 2;
repeated FieldDescriptorProto extension = 6;
repeated DescriptorProto nested_type = 3;
repeated EnumDescriptorProto enum_type = 4;
message ExtensionRange {
optional int32 start = 1;
optional int32 end = 2;
}
repeated ExtensionRange extension_range = 5;
repeated OneofDescriptorProto oneof_decl = 8;
optional MessageOptions options = 7;
}
// Describes a field within a message.
message FieldDescriptorProto {
enum Type {
// 0 is reserved for errors.
// Order is weird for historical reasons.
TYPE_DOUBLE = 1;
TYPE_FLOAT = 2;
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
// negative values are likely.
TYPE_INT64 = 3;
TYPE_UINT64 = 4;
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
// negative values are likely.
TYPE_INT32 = 5;
TYPE_FIXED64 = 6;
TYPE_FIXED32 = 7;
TYPE_BOOL = 8;
TYPE_STRING = 9;
TYPE_GROUP = 10; // Tag-delimited aggregate.
TYPE_MESSAGE = 11; // Length-delimited aggregate.
// New in version 2.
TYPE_BYTES = 12;
TYPE_UINT32 = 13;
TYPE_ENUM = 14;
TYPE_SFIXED32 = 15;
TYPE_SFIXED64 = 16;
TYPE_SINT32 = 17; // Uses ZigZag encoding.
TYPE_SINT64 = 18; // Uses ZigZag encoding.
};
enum Label {
// 0 is reserved for errors
LABEL_OPTIONAL = 1;
LABEL_REQUIRED = 2;
LABEL_REPEATED = 3;
// TODO(sanjay): Should we add LABEL_MAP?
};
optional string name = 1;
optional int32 number = 3;
optional Label label = 4;
// If type_name is set, this need not be set. If both this and type_name
// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
optional Type type = 5;
// For message and enum types, this is the name of the type. If the name
// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
// rules are used to find the type (i.e. first the nested types within this
// message are searched, then within the parent, on up to the root
// namespace).
optional string type_name = 6;
// For extensions, this is the name of the type being extended. It is
// resolved in the same manner as type_name.
optional string extendee = 2;
// For numeric types, contains the original text representation of the value.
// For booleans, "true" or "false".
// For strings, contains the default text contents (not escaped in any way).
// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
// TODO(kenton): Base-64 encode?
optional string default_value = 7;
// If set, gives the index of a oneof in the containing type's oneof_decl
// list. This field is a member of that oneof. Extensions of a oneof should
// not set this since the oneof to which they belong will be inferred based
// on the extension range containing the extension's field number.
optional int32 oneof_index = 9;
optional FieldOptions options = 8;
}
// Describes a oneof.
message OneofDescriptorProto {
optional string name = 1;
}
// Describes an enum type.
message EnumDescriptorProto {
optional string name = 1;
repeated EnumValueDescriptorProto value = 2;
optional EnumOptions options = 3;
}
// Describes a value within an enum.
message EnumValueDescriptorProto {
optional string name = 1;
optional int32 number = 2;
optional EnumValueOptions options = 3;
}
// Describes a service.
message ServiceDescriptorProto {
optional string name = 1;
repeated MethodDescriptorProto method = 2;
optional ServiceOptions options = 3;
}
// Describes a method of a service.
message MethodDescriptorProto {
optional string name = 1;
// Input and output type names. These are resolved in the same way as
// FieldDescriptorProto.type_name, but must refer to a message type.
optional string input_type = 2;
optional string output_type = 3;
optional MethodOptions options = 4;
// Identifies if client streams multiple client messages
optional bool client_streaming = 5 [default=false];
// Identifies if server streams multiple server messages
optional bool server_streaming = 6 [default=false];
}
// ===================================================================
// Options
// Each of the definitions above may have "options" attached. These are
// just annotations which may cause code to be generated slightly differently
// or may contain hints for code that manipulates protocol messages.
//
// Clients may define custom options as extensions of the *Options messages.
// These extensions may not yet be known at parsing time, so the parser cannot
// store the values in them. Instead it stores them in a field in the *Options
// message called uninterpreted_option. This field must have the same name
// across all *Options messages. We then use this field to populate the
// extensions when we build a descriptor, at which point all protos have been
// parsed and so all extensions are known.
//
// Extension numbers for custom options may be chosen as follows:
// * For options which will only be used within a single application or
// organization, or for experimental options, use field numbers 50000
// through 99999. It is up to you to ensure that you do not use the
// same number for multiple options.
// * For options which will be published and used publicly by multiple
// independent entities, e-mail protobuf-global-extension-registry@google.com
// to reserve extension numbers. Simply provide your project name (e.g.
// Object-C plugin) and your porject website (if available) -- there's no need
// to explain how you intend to use them. Usually you only need one extension
// number. You can declare multiple options with only one extension number by
// putting them in a sub-message. See the Custom Options section of the docs
// for examples:
// https://developers.google.com/protocol-buffers/docs/proto#options
// If this turns out to be popular, a web service will be set up
// to automatically assign option numbers.
message FileOptions {
// Sets the Java package where classes generated from this .proto will be
// placed. By default, the proto package is used, but this is often
// inappropriate because proto packages do not normally start with backwards
// domain names.
optional string java_package = 1;
// If set, all the classes from the .proto file are wrapped in a single
// outer class with the given name. This applies to both Proto1
// (equivalent to the old "--one_java_file" option) and Proto2 (where
// a .proto always translates to a single class, but you may want to
// explicitly choose the class name).
optional string java_outer_classname = 8;
// If set true, then the Java code generator will generate a separate .java
// file for each top-level message, enum, and service defined in the .proto
// file. Thus, these types will *not* be nested inside the outer class
// named by java_outer_classname. However, the outer class will still be
// generated to contain the file's getDescriptor() method as well as any
// top-level extensions defined in the file.
optional bool java_multiple_files = 10 [default=false];
// If set true, then the Java code generator will generate equals() and
// hashCode() methods for all messages defined in the .proto file.
// - In the full runtime, this is purely a speed optimization, as the
// AbstractMessage base class includes reflection-based implementations of
// these methods.
//- In the lite runtime, setting this option changes the semantics of
// equals() and hashCode() to more closely match those of the full runtime;
// the generated methods compute their results based on field values rather
// than object identity. (Implementations should not assume that hashcodes
// will be consistent across runtimes or versions of the protocol compiler.)
optional bool java_generate_equals_and_hash = 20 [default=false];
// If set true, then the Java2 code generator will generate code that
// throws an exception whenever an attempt is made to assign a non-UTF-8
// byte sequence to a string field.
// Message reflection will do the same.
// However, an extension field still accepts non-UTF-8 byte sequences.
// This option has no effect on when used with the lite runtime.
optional bool java_string_check_utf8 = 27 [default=false];
// Generated classes can be optimized for speed or code size.
enum OptimizeMode {
SPEED = 1; // Generate complete code for parsing, serialization,
// etc.
CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
}
optional OptimizeMode optimize_for = 9 [default=SPEED];
// Sets the Go package where structs generated from this .proto will be
// placed. If omitted, the Go package will be derived from the following:
// - The basename of the package import path, if provided.
// - Otherwise, the package statement in the .proto file, if present.
// - Otherwise, the basename of the .proto file, without extension.
optional string go_package = 11;
// Should generic services be generated in each language? "Generic" services
// are not specific to any particular RPC system. They are generated by the
// main code generators in each language (without additional plugins).
// Generic services were the only kind of service generation supported by
// early versions of google.protobuf.
//
// Generic services are now considered deprecated in favor of using plugins
// that generate code specific to your particular RPC system. Therefore,
// these default to false. Old code which depends on generic services should
// explicitly set them to true.
optional bool cc_generic_services = 16 [default=false];
optional bool java_generic_services = 17 [default=false];
optional bool py_generic_services = 18 [default=false];
// Is this file deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for everything in the file, or it will be completely ignored; in the very
// least, this is a formalization for deprecating files.
optional bool deprecated = 23 [default=false];
// Enables the use of arenas for the proto messages in this file. This applies
// only to generated classes for C++.
optional bool cc_enable_arenas = 31 [default=false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message MessageOptions {
// Set true to use the old proto1 MessageSet wire format for extensions.
// This is provided for backwards-compatibility with the MessageSet wire
// format. You should not use this for any other reason: It's less
// efficient, has fewer features, and is more complicated.
//
// The message must be defined exactly as follows:
// message Foo {
// option message_set_wire_format = true;
// extensions 4 to max;
// }
// Note that the message cannot have any defined fields; MessageSets only
// have extensions.
//
// All extensions of your type must be singular messages; e.g. they cannot
// be int32s, enums, or repeated messages.
//
// Because this is an option, the above two restrictions are not enforced by
// the protocol compiler.
optional bool message_set_wire_format = 1 [default=false];
// Disables the generation of the standard "descriptor()" accessor, which can
// conflict with a field of the same name. This is meant to make migration
// from proto1 easier; new code should avoid fields named "descriptor".
optional bool no_standard_descriptor_accessor = 2 [default=false];
// Is this message deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the message, or it will be completely ignored; in the very least,
// this is a formalization for deprecating messages.
optional bool deprecated = 3 [default=false];
// Whether the message is an automatically generated map entry type for the
// maps field.
//
// For maps fields:
// map<KeyType, ValueType> map_field = 1;
// The parsed descriptor looks like:
// message MapFieldEntry {
// option map_entry = true;
// optional KeyType key = 1;
// optional ValueType value = 2;
// }
// repeated MapFieldEntry map_field = 1;
//
// Implementations may choose not to generate the map_entry=true message, but
// use a native map in the target language to hold the keys and values.
// The reflection APIs in such implementions still need to work as
// if the field is a repeated message field.
//
// NOTE: Do not set the option in .proto files. Always use the maps syntax
// instead. The option should only be implicitly set by the proto compiler
// parser.
optional bool map_entry = 7;
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message FieldOptions {
// The ctype option instructs the C++ code generator to use a different
// representation of the field than it normally would. See the specific
// options below. This option is not yet implemented in the open source
// release -- sorry, we'll try to include it in a future version!
optional CType ctype = 1 [default = STRING];
enum CType {
// Default mode.
STRING = 0;
CORD = 1;
STRING_PIECE = 2;
}
// The packed option can be enabled for repeated primitive fields to enable
// a more efficient representation on the wire. Rather than repeatedly
// writing the tag and type for each element, the entire array is encoded as
// a single length-delimited blob.
optional bool packed = 2;
// Should this field be parsed lazily? Lazy applies only to message-type
// fields. It means that when the outer message is initially parsed, the
// inner message's contents will not be parsed but instead stored in encoded
// form. The inner message will actually be parsed when it is first accessed.
//
// This is only a hint. Implementations are free to choose whether to use
// eager or lazy parsing regardless of the value of this option. However,
// setting this option true suggests that the protocol author believes that
// using lazy parsing on this field is worth the additional bookkeeping
// overhead typically needed to implement it.
//
// This option does not affect the public interface of any generated code;
// all method signatures remain the same. Furthermore, thread-safety of the
// interface is not affected by this option; const methods remain safe to
// call from multiple threads concurrently, while non-const methods continue
// to require exclusive access.
//
//
// Note that implementations may choose not to check required fields within
// a lazy sub-message. That is, calling IsInitialized() on the outher message
// may return true even if the inner message has missing required fields.
// This is necessary because otherwise the inner message would have to be
// parsed in order to perform the check, defeating the purpose of lazy
// parsing. An implementation which chooses not to check required fields
// must be consistent about it. That is, for any particular sub-message, the
// implementation must either *always* check its required fields, or *never*
// check its required fields, regardless of whether or not the message has
// been parsed.
optional bool lazy = 5 [default=false];
// Is this field deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for accessors, or it will be completely ignored; in the very least, this
// is a formalization for deprecating fields.
optional bool deprecated = 3 [default=false];
// For Google-internal migration only. Do not use.
optional bool weak = 10 [default=false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message EnumOptions {
// Set this option to true to allow mapping different tag names to the same
// value.
optional bool allow_alias = 2;
// Is this enum deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the enum, or it will be completely ignored; in the very least, this
// is a formalization for deprecating enums.
optional bool deprecated = 3 [default=false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message EnumValueOptions {
// Is this enum value deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the enum value, or it will be completely ignored; in the very least,
// this is a formalization for deprecating enum values.
optional bool deprecated = 1 [default=false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message ServiceOptions {
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
// framework. We apologize for hoarding these numbers to ourselves, but
// we were already using them long before we decided to release Protocol
// Buffers.
// Is this service deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the service, or it will be completely ignored; in the very least,
// this is a formalization for deprecating services.
optional bool deprecated = 33 [default=false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message MethodOptions {
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
// framework. We apologize for hoarding these numbers to ourselves, but
// we were already using them long before we decided to release Protocol
// Buffers.
// Is this method deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the method, or it will be completely ignored; in the very least,
// this is a formalization for deprecating methods.
optional bool deprecated = 33 [default=false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
// A message representing a option the parser does not recognize. This only
// appears in options protos created by the compiler::Parser class.
// DescriptorPool resolves these when building Descriptor objects. Therefore,
// options protos in descriptor objects (e.g. returned by Descriptor::options(),
// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
// in them.
message UninterpretedOption {
// The name of the uninterpreted option. Each string represents a segment in
// a dot-separated name. is_extension is true iff a segment represents an
// extension (denoted with parentheses in options specs in .proto files).
// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
// "foo.(bar.baz).qux".
message NamePart {
required string name_part = 1;
required bool is_extension = 2;
}
repeated NamePart name = 2;
// The value of the uninterpreted option, in whatever type the tokenizer
// identified it as during parsing. Exactly one of these should be set.
optional string identifier_value = 3;
optional uint64 positive_int_value = 4;
optional int64 negative_int_value = 5;
optional double double_value = 6;
optional bytes string_value = 7;
optional string aggregate_value = 8;
}
// ===================================================================
// Optional source code info
// Encapsulates information about the original source file from which a
// FileDescriptorProto was generated.
message SourceCodeInfo {
// A Location identifies a piece of source code in a .proto file which
// corresponds to a particular definition. This information is intended
// to be useful to IDEs, code indexers, documentation generators, and similar
// tools.
//
// For example, say we have a file like:
// message Foo {
// optional string foo = 1;
// }
// Let's look at just the field definition:
// optional string foo = 1;
// ^ ^^ ^^ ^ ^^^
// a bc de f ghi
// We have the following locations:
// span path represents
// [a,i) [ 4, 0, 2, 0 ] The whole field definition.
// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
// [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
// [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
//
// Notes:
// - A location may refer to a repeated field itself (i.e. not to any
// particular index within it). This is used whenever a set of elements are
// logically enclosed in a single code segment. For example, an entire
// extend block (possibly containing multiple extension definitions) will
// have an outer location whose path refers to the "extensions" repeated
// field without an index.
// - Multiple locations may have the same path. This happens when a single
// logical declaration is spread out across multiple places. The most
// obvious example is the "extend" block again -- there may be multiple
// extend blocks in the same scope, each of which will have the same path.
// - A location's span is not always a subset of its parent's span. For
// example, the "extendee" of an extension declaration appears at the
// beginning of the "extend" block and is shared by all extensions within
// the block.
// - Just because a location's span is a subset of some other location's span
// does not mean that it is a descendent. For example, a "group" defines
// both a type and a field in a single declaration. Thus, the locations
// corresponding to the type and field and their components will overlap.
// - Code which tries to interpret locations should probably be designed to
// ignore those that it doesn't understand, as more types of locations could
// be recorded in the future.
repeated Location location = 1;
message Location {
// Identifies which part of the FileDescriptorProto was defined at this
// location.
//
// Each element is a field number or an index. They form a path from
// the root FileDescriptorProto to the place where the definition. For
// example, this path:
// [ 4, 3, 2, 7, 1 ]
// refers to:
// file.message_type(3) // 4, 3
// .field(7) // 2, 7
// .name() // 1
// This is because FileDescriptorProto.message_type has field number 4:
// repeated DescriptorProto message_type = 4;
// and DescriptorProto.field has field number 2:
// repeated FieldDescriptorProto field = 2;
// and FieldDescriptorProto.name has field number 1:
// optional string name = 1;
//
// Thus, the above path gives the location of a field name. If we removed
// the last element:
// [ 4, 3, 2, 7 ]
// this path refers to the whole field declaration (from the beginning
// of the label to the terminating semicolon).
repeated int32 path = 1 [packed=true];
// Always has exactly three or four elements: start line, start column,
// end line (optional, otherwise assumed same as start line), end column.
// These are packed into a single field for efficiency. Note that line
// and column numbers are zero-based -- typically you will want to add
// 1 to each before displaying to a user.
repeated int32 span = 2 [packed=true];
// If this SourceCodeInfo represents a complete declaration, these are any
// comments appearing before and after the declaration which appear to be
// attached to the declaration.
//
// A series of line comments appearing on consecutive lines, with no other
// tokens appearing on those lines, will be treated as a single comment.
//
// Only the comment content is provided; comment markers (e.g. //) are
// stripped out. For block comments, leading whitespace and an asterisk
// will be stripped from the beginning of each line other than the first.
// Newlines are included in the output.
//
// Examples:
//
// optional int32 foo = 1; // Comment attached to foo.
// // Comment attached to bar.
// optional int32 bar = 2;
//
// optional string baz = 3;
// // Comment attached to baz.
// // Another line attached to baz.
//
// // Comment attached to qux.
// //
// // Another line attached to qux.
// optional double qux = 4;
//
// optional string corge = 5;
// /* Block comment attached
// * to corge. Leading asterisks
// * will be removed. */
// /* Block comment attached to
// * grault. */
// optional int32 grault = 6;
optional string leading_comments = 3;
optional string trailing_comments = 4;
}
}
\ No newline at end of file
// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
// http://github.com/gogo/protobuf/gogoproto
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"QmfH4HuZyN1p2wQLWWkXC91Z76435xKrBVfLQ2MY8ayG5R/gogo-protobuf/version"
)
type MixMatch struct {
Old []string
Filename string
Args []string
Plugins string
}
func (this MixMatch) Gen(folder string, news []string) {
if err := os.MkdirAll(folder, 0777); err != nil {
panic(err)
}
data, err := ioutil.ReadFile(this.Filename)
if err != nil {
panic(err)
}
content := string(data)
for i, old := range this.Old {
if !strings.Contains(content, old) {
panic(fmt.Errorf("could not find string {%s} to replace with {%s}", old, news[i]))
}
content = strings.Replace(content, old, news[i], 1)
if strings.Contains(content, old) && old != news[i] {
panic(fmt.Errorf("found another string {%s} after it was replaced with {%s}", old, news[i]))
}
}
if err := ioutil.WriteFile(filepath.Join(folder, this.Filename), []byte(content), 0666); err != nil {
panic(err)
}
args := append([]string{"--gogo_out=" + this.Plugins + "."}, this.Args...)
args = append(args, filepath.Join(folder, this.Filename))
var regenerate = exec.Command("protoc", args...)
out, err := regenerate.CombinedOutput()
failed := false
scanner := bufio.NewScanner(bytes.NewReader(out))
for scanner.Scan() {
text := scanner.Text()
fmt.Println("protoc-gen-combo: ", text)
if !strings.Contains(text, "WARNING") {
failed = true
}
}
if err != nil {
fmt.Print("protoc-gen-combo: error: ", err)
failed = true
}
if failed {
os.Exit(1)
}
}
var min = flag.String("version", "2.3.0", "minimum protoc version")
var proto_path = flag.String("proto_path", ".", "")
var def = flag.Bool("default", true, "generate the case where everything is false")
var plugins = flag.String("plugins", "", "--gogo_out=plugins=<plugins>:.")
func main() {
flag.Parse()
if !version.AtLeast(*min) {
fmt.Printf("protoc version not high enough to parse this proto file\n")
return
}
args := flag.Args()
filename := args[0]
args = append([]string{"--proto_path=" + *proto_path})
if _, err := exec.LookPath("protoc"); err != nil {
panic("cannot find protoc in PATH")
}
pluginStr := ""
if len(*plugins) > 0 {
pluginStr = "plugins=" + *plugins + ":"
}
m := MixMatch{
Old: []string{
"option (gogoproto.unmarshaler_all) = false;",
"option (gogoproto.marshaler_all) = false;",
"option (gogoproto.unsafe_unmarshaler_all) = false;",
"option (gogoproto.unsafe_marshaler_all) = false;",
},
Filename: filename,
Args: args,
Plugins: pluginStr,
}
if *def {
m.Gen("./combos/neither/", []string{
"option (gogoproto.unmarshaler_all) = false;",
"option (gogoproto.marshaler_all) = false;",
"option (gogoproto.unsafe_unmarshaler_all) = false;",
"option (gogoproto.unsafe_marshaler_all) = false;",
})
}
m.Gen("./combos/marshaler/", []string{
"option (gogoproto.unmarshaler_all) = false;",
"option (gogoproto.marshaler_all) = true;",
"option (gogoproto.unsafe_unmarshaler_all) = false;",
"option (gogoproto.unsafe_marshaler_all) = false;",
})
m.Gen("./combos/unmarshaler/", []string{
"option (gogoproto.unmarshaler_all) = true;",
"option (gogoproto.marshaler_all) = false;",
"option (gogoproto.unsafe_unmarshaler_all) = false;",
"option (gogoproto.unsafe_marshaler_all) = false;",
})
m.Gen("./combos/both/", []string{
"option (gogoproto.unmarshaler_all) = true;",
"option (gogoproto.marshaler_all) = true;",
"option (gogoproto.unsafe_unmarshaler_all) = false;",
"option (gogoproto.unsafe_marshaler_all) = false;",
})
m.Gen("./combos/unsafemarshaler/", []string{
"option (gogoproto.unmarshaler_all) = false;",
"option (gogoproto.marshaler_all) = false;",
"option (gogoproto.unsafe_unmarshaler_all) = false;",
"option (gogoproto.unsafe_marshaler_all) = true;",
})
m.Gen("./combos/unsafeunmarshaler/", []string{
"option (gogoproto.unmarshaler_all) = false;",
"option (gogoproto.marshaler_all) = false;",
"option (gogoproto.unsafe_unmarshaler_all) = true;",
"option (gogoproto.unsafe_marshaler_all) = false;",
})
m.Gen("./combos/unsafeboth/", []string{
"option (gogoproto.unmarshaler_all) = false;",
"option (gogoproto.marshaler_all) = false;",
"option (gogoproto.unsafe_unmarshaler_all) = true;",
"option (gogoproto.unsafe_marshaler_all) = true;",
})
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment