Skip to content

Instantly share code, notes, and snippets.

@deckarep
Last active July 2, 2020 01:26
Show Gist options
  • Save deckarep/462f147f195fe6fc2601a3359cdd84e1 to your computer and use it in GitHub Desktop.
Save deckarep/462f147f195fe6fc2601a3359cdd84e1 to your computer and use it in GitHub Desktop.
Protobuf Talk: Output of protoc command.
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: dog.proto
package main
import (
encoding_binary "encoding/binary"
fmt "fmt"
github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type Dog struct {
OwnerId *int32 `protobuf:"varint,1,req,name=owner_id,json=ownerId" json:"owner_id,omitempty"`
Breed *string `protobuf:"bytes,2,opt,name=breed" json:"breed,omitempty"`
HeightIn *float32 `protobuf:"fixed32,3,opt,name=height_in,json=heightIn" json:"height_in,omitempty"`
Color *string `protobuf:"bytes,4,opt,name=color" json:"color,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Dog) Reset() { *m = Dog{} }
func (m *Dog) String() string { return proto.CompactTextString(m) }
func (*Dog) ProtoMessage() {}
func (*Dog) Descriptor() ([]byte, []int) {
return fileDescriptor_ea9c529e4c32f343, []int{0}
}
func (m *Dog) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Dog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Dog.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Dog) XXX_Merge(src proto.Message) {
xxx_messageInfo_Dog.Merge(m, src)
}
func (m *Dog) XXX_Size() int {
return m.Size()
}
func (m *Dog) XXX_DiscardUnknown() {
xxx_messageInfo_Dog.DiscardUnknown(m)
}
var xxx_messageInfo_Dog proto.InternalMessageInfo
func (m *Dog) GetOwnerId() int32 {
if m != nil && m.OwnerId != nil {
return *m.OwnerId
}
return 0
}
func (m *Dog) GetBreed() string {
if m != nil && m.Breed != nil {
return *m.Breed
}
return ""
}
func (m *Dog) GetHeightIn() float32 {
if m != nil && m.HeightIn != nil {
return *m.HeightIn
}
return 0
}
func (m *Dog) GetColor() string {
if m != nil && m.Color != nil {
return *m.Color
}
return ""
}
func init() {
proto.RegisterType((*Dog)(nil), "Dog")
}
func init() { proto.RegisterFile("dog.proto", fileDescriptor_ea9c529e4c32f343) }
var fileDescriptor_ea9c529e4c32f343 = []byte{
// 142 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4c, 0xc9, 0x4f, 0xd7,
0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57, 0xca, 0xe4, 0x62, 0x76, 0xc9, 0x4f, 0x17, 0x92, 0xe4, 0xe2,
0xc8, 0x2f, 0xcf, 0x4b, 0x2d, 0x8a, 0xcf, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd2, 0x60, 0x0d, 0x62,
0x07, 0xf3, 0x3d, 0x53, 0x84, 0x44, 0xb8, 0x58, 0x93, 0x8a, 0x52, 0x53, 0x53, 0x24, 0x98, 0x14,
0x18, 0x35, 0x38, 0x83, 0x20, 0x1c, 0x21, 0x69, 0x2e, 0xce, 0x8c, 0xd4, 0xcc, 0xf4, 0x8c, 0x92,
0xf8, 0xcc, 0x3c, 0x09, 0x66, 0x05, 0x46, 0x0d, 0xa6, 0x20, 0x0e, 0x88, 0x80, 0x67, 0x1e, 0x48,
0x4b, 0x72, 0x7e, 0x4e, 0x7e, 0x91, 0x04, 0x0b, 0x44, 0x0b, 0x98, 0xe3, 0x24, 0x74, 0xe2, 0x91,
0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x46, 0xb1, 0xe4, 0x26, 0x66, 0xe6,
0x01, 0x02, 0x00, 0x00, 0xff, 0xff, 0x18, 0x56, 0x3d, 0xae, 0x8a, 0x00, 0x00, 0x00,
}
func (m *Dog) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Dog) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.OwnerId == nil {
return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("owner_id")
} else {
dAtA[i] = 0x8
i++
i = encodeVarintDog(dAtA, i, uint64(*m.OwnerId))
}
if m.Breed != nil {
dAtA[i] = 0x12
i++
i = encodeVarintDog(dAtA, i, uint64(len(*m.Breed)))
i += copy(dAtA[i:], *m.Breed)
}
if m.HeightIn != nil {
dAtA[i] = 0x1d
i++
encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(*m.HeightIn))))
i += 4
}
if m.Color != nil {
dAtA[i] = 0x22
i++
i = encodeVarintDog(dAtA, i, uint64(len(*m.Color)))
i += copy(dAtA[i:], *m.Color)
}
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
}
return i, nil
}
func encodeVarintDog(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *Dog) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.OwnerId != nil {
n += 1 + sovDog(uint64(*m.OwnerId))
}
if m.Breed != nil {
l = len(*m.Breed)
n += 1 + l + sovDog(uint64(l))
}
if m.HeightIn != nil {
n += 5
}
if m.Color != nil {
l = len(*m.Color)
n += 1 + l + sovDog(uint64(l))
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func sovDog(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozDog(x uint64) (n int) {
return sovDog(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *Dog) Unmarshal(dAtA []byte) error {
var hasFields [1]uint64
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDog
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Dog: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Dog: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field OwnerId", wireType)
}
var v int32
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDog
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= int32(b&0x7F) << shift
if b < 0x80 {
break
}
}
m.OwnerId = &v
hasFields[0] |= uint64(0x00000001)
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Breed", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDog
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthDog
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthDog
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
s := string(dAtA[iNdEx:postIndex])
m.Breed = &s
iNdEx = postIndex
case 3:
if wireType != 5 {
return fmt.Errorf("proto: wrong wireType = %d for field HeightIn", wireType)
}
var v uint32
if (iNdEx + 4) > l {
return io.ErrUnexpectedEOF
}
v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:]))
iNdEx += 4
v2 := float32(math.Float32frombits(v))
m.HeightIn = &v2
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Color", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDog
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthDog
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthDog
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
s := string(dAtA[iNdEx:postIndex])
m.Color = &s
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipDog(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthDog
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthDog
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
iNdEx += skippy
}
}
if hasFields[0]&uint64(0x00000001) == 0 {
return github_com_gogo_protobuf_proto.NewRequiredNotSetError("owner_id")
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipDog(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowDog
}
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 shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowDog
}
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 shift >= 64 {
return 0, ErrIntOverflowDog
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthDog
}
iNdEx += length
if iNdEx < 0 {
return 0, ErrInvalidLengthDog
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowDog
}
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 := skipDog(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthDog
}
}
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")
}
var (
ErrInvalidLengthDog = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowDog = fmt.Errorf("proto: integer overflow")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment