diff --git a/go.mod b/go.mod index 5a45923..d780917 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ -module github.com/libp2p/go-msgio +module github.com/xmtp/go-msgio go 1.17 require ( - github.com/gogo/protobuf v1.3.2 github.com/libp2p/go-buffer-pool v0.0.2 github.com/multiformats/go-varint v0.0.6 + google.golang.org/protobuf v1.28.0 ) diff --git a/go.sum b/go.sum index 7f286e1..d632f9c 100644 --- a/go.sum +++ b/go.sum @@ -1,35 +1,12 @@ -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/msgio/msgio.go b/msgio/msgio.go index a4293d3..03b629f 100644 --- a/msgio/msgio.go +++ b/msgio/msgio.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - msgio "github.com/libp2p/go-msgio" + msgio "github.com/xmtp/go-msgio" ) var Args ArgType diff --git a/protoio/interfaces.go b/protoio/interfaces.go index 1a42713..a6e39b9 100644 --- a/protoio/interfaces.go +++ b/protoio/interfaces.go @@ -35,7 +35,7 @@ package protoio import ( "io" - "github.com/gogo/protobuf/proto" + "google.golang.org/protobuf/proto" ) type Writer interface { @@ -55,17 +55,3 @@ type ReadCloser interface { Reader io.Closer } - -func getSize(v interface{}) (int, bool) { - if sz, ok := v.(interface { - Size() (n int) - }); ok { - return sz.Size(), true - } else if sz, ok := v.(interface { - ProtoSize() (n int) - }); ok { - return sz.ProtoSize(), true - } else { - return 0, false - } -} diff --git a/protoio/uvarint_reader.go b/protoio/uvarint_reader.go index 1173467..c0f2afb 100644 --- a/protoio/uvarint_reader.go +++ b/protoio/uvarint_reader.go @@ -39,9 +39,8 @@ import ( "os" "runtime/debug" - "github.com/gogo/protobuf/proto" - "github.com/multiformats/go-varint" + "google.golang.org/protobuf/proto" ) type uvarintReader struct { diff --git a/protoio/uvarint_test.go b/protoio/uvarint_test.go index 0cde5b2..99585ff 100644 --- a/protoio/uvarint_test.go +++ b/protoio/uvarint_test.go @@ -34,15 +34,16 @@ package protoio_test import ( "bytes" + "fmt" "io" "math/rand" "testing" "time" - "github.com/gogo/protobuf/test" + "github.com/xmtp/go-msgio/test" - "github.com/libp2p/go-msgio/protoio" "github.com/multiformats/go-varint" + "github.com/xmtp/go-msgio/protoio" ) func TestVarintNormal(t *testing.T) { @@ -109,15 +110,7 @@ func iotest(writer protoio.WriteCloser, reader protoio.ReadCloser) error { msgs := make([]*test.NinOptNative, size) r := rand.New(rand.NewSource(time.Now().UnixNano())) for i := range msgs { - msgs[i] = test.NewPopulatedNinOptNative(r, true) - // https://github.com/gogo/protobuf/issues/31 - if i == 5 { - msgs[i] = &test.NinOptNative{} - } - // https://github.com/gogo/protobuf/issues/31 - if i == 999 { - msgs[i] = &test.NinOptNative{} - } + msgs[i] = NewPopulatedNinOptNative(r, true) err := writer.WriteMsg(msgs[i]) if err != nil { return err @@ -135,7 +128,7 @@ func iotest(writer protoio.WriteCloser, reader protoio.ReadCloser) error { } return err } - if err := msg.VerboseEqual(msgs[i]); err != nil { + if err := verboseEqual(msg, msgs[i]); err != nil { return err } i++ @@ -148,3 +141,189 @@ func iotest(writer protoio.WriteCloser, reader protoio.ReadCloser) error { } return nil } + +// Everything below this line is borrowed from the generated test code in gogoproto +// -------------------------------------------------------------------------------- +type randyThetest interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func verboseEqual(this *test.NinOptNative, that1 *test.NinOptNative) error { + if that1 == nil { + if this == nil { + return nil + } + return fmt.Errorf("that == nil && this != nil") + } + if that1 == nil { + if this == nil { + return nil + } + return fmt.Errorf("that is type *NidOptNative but is nil && this != nil") + } else if this == nil { + return fmt.Errorf("that is type *NidOptNative but is not nil && this == nil") + } + if this.GetField1() != that1.GetField1() { + return fmt.Errorf("Field1 this(%v) Not Equal that(%v)", this.Field1, that1.Field1) + } + if this.GetField2() != that1.GetField2() { + return fmt.Errorf("Field2 this(%v) Not Equal that(%v)", this.Field2, that1.Field2) + } + if this.GetField3() != that1.GetField3() { + return fmt.Errorf("GetField3() this(%v) Not Equal that(%v)", this.GetField3(), that1.GetField3()) + } + if this.GetField4() != that1.GetField4() { + return fmt.Errorf("GetField4() this(%v) Not Equal that(%v)", this.GetField4(), that1.GetField4()) + } + if this.GetField5() != that1.GetField5() { + return fmt.Errorf("GetField5() this(%v) Not Equal that(%v)", this.GetField5(), that1.GetField5()) + } + if this.GetField6() != that1.GetField6() { + return fmt.Errorf("GetField6() this(%v) Not Equal that(%v)", this.GetField6(), that1.GetField6()) + } + if this.GetField7() != that1.GetField7() { + return fmt.Errorf("GetField7() this(%v) Not Equal that(%v)", this.GetField7(), that1.GetField7()) + } + if this.GetField8() != that1.GetField8() { + return fmt.Errorf("GetField8() this(%v) Not Equal that(%v)", this.GetField8(), that1.GetField8()) + } + if this.GetField9() != that1.GetField9() { + return fmt.Errorf("GetField9() this(%v) Not Equal that(%v)", this.GetField9(), that1.GetField9()) + } + if this.GetField10() != that1.GetField10() { + return fmt.Errorf("GetField10() this(%v) Not Equal that(%v)", this.GetField10(), that1.GetField10()) + } + if this.GetField11() != that1.GetField11() { + return fmt.Errorf("GetField11() this(%v) Not Equal that(%v)", this.GetField11(), that1.GetField11()) + } + if this.GetField12() != that1.GetField12() { + return fmt.Errorf("GetField12() this(%v) Not Equal that(%v)", this.GetField12(), that1.GetField12()) + } + if this.GetField13() != that1.GetField13() { + return fmt.Errorf("GetField13() this(%v) Not Equal that(%v)", this.GetField13(), that1.GetField13()) + } + if this.GetField14() != that1.GetField14() { + return fmt.Errorf("GetField14() this(%v) Not Equal that(%v)", this.GetField14(), that1.GetField14()) + } + if !bytes.Equal(this.Field15, that1.Field15) { + return fmt.Errorf("Field15 this(%v) Not Equal that(%v)", this.Field15, that1.Field15) + } + return nil +} + +func NewPopulatedNinOptNative(r randyThetest, easy bool) *test.NinOptNative { + this := &test.NinOptNative{} + if r.Intn(5) != 0 { + v2 := float64(r.Float64()) + if r.Intn(2) == 0 { + v2 *= -1 + } + this.Field1 = &v2 + } + if r.Intn(5) != 0 { + v3 := float32(r.Float32()) + if r.Intn(2) == 0 { + v3 *= -1 + } + this.Field2 = &v3 + } + if r.Intn(5) != 0 { + v4 := int32(r.Int31()) + if r.Intn(2) == 0 { + v4 *= -1 + } + this.Field3 = &v4 + } + if r.Intn(5) != 0 { + v5 := int64(r.Int63()) + if r.Intn(2) == 0 { + v5 *= -1 + } + this.Field4 = &v5 + } + if r.Intn(5) != 0 { + v6 := uint32(r.Uint32()) + this.Field5 = &v6 + } + if r.Intn(5) != 0 { + v7 := uint64(uint64(r.Uint32())) + this.Field6 = &v7 + } + if r.Intn(5) != 0 { + v8 := int32(r.Int31()) + if r.Intn(2) == 0 { + v8 *= -1 + } + this.Field7 = &v8 + } + if r.Intn(5) != 0 { + v9 := int64(r.Int63()) + if r.Intn(2) == 0 { + v9 *= -1 + } + this.Field8 = &v9 + } + if r.Intn(5) != 0 { + v10 := uint32(r.Uint32()) + this.Field9 = &v10 + } + if r.Intn(5) != 0 { + v11 := int32(r.Int31()) + if r.Intn(2) == 0 { + v11 *= -1 + } + this.Field10 = &v11 + } + if r.Intn(5) != 0 { + v12 := uint64(uint64(r.Uint32())) + this.Field11 = &v12 + } + if r.Intn(5) != 0 { + v13 := int64(r.Int63()) + if r.Intn(2) == 0 { + v13 *= -1 + } + this.Field12 = &v13 + } + if r.Intn(5) != 0 { + v14 := bool(bool(r.Intn(2) == 0)) + this.Field13 = &v14 + } + if r.Intn(5) != 0 { + v15 := string(randStringThetest(r)) + this.Field14 = &v15 + } + if r.Intn(5) != 0 { + v16 := r.Intn(100) + this.Field15 = make([]byte, v16) + for i := 0; i < v16; i++ { + this.Field15[i] = byte(r.Intn(256)) + } + } + + return this +} + +func randStringThetest(r randyThetest) string { + v258 := r.Intn(100) + tmps := make([]rune, v258) + for i := 0; i < v258; i++ { + tmps[i] = randUTF8RuneThetest(r) + } + return string(tmps) +} + +func randUTF8RuneThetest(r randyThetest) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} diff --git a/protoio/uvarint_writer.go b/protoio/uvarint_writer.go index ace982e..0bbf913 100644 --- a/protoio/uvarint_writer.go +++ b/protoio/uvarint_writer.go @@ -38,7 +38,7 @@ import ( "os" "runtime/debug" - "github.com/gogo/protobuf/proto" + "google.golang.org/protobuf/proto" "github.com/multiformats/go-varint" ) @@ -62,25 +62,6 @@ func (uw *uvarintWriter) WriteMsg(msg proto.Message) (err error) { }() var data []byte - if m, ok := msg.(interface { - MarshalTo(data []byte) (n int, err error) - }); ok { - n, ok := getSize(m) - if ok { - if n+varint.MaxLenUvarint63 >= len(uw.buffer) { - uw.buffer = make([]byte, n+varint.MaxLenUvarint63) - } - lenOff := varint.PutUvarint(uw.buffer, uint64(n)) - _, err = m.MarshalTo(uw.buffer[lenOff:]) - if err != nil { - return err - } - _, err = uw.w.Write(uw.buffer[:lenOff+n]) - return err - } - } - - // fallback data, err = proto.Marshal(msg) if err != nil { return err diff --git a/test/test.pb.go b/test/test.pb.go new file mode 100644 index 0000000..af0a4b4 --- /dev/null +++ b/test/test.pb.go @@ -0,0 +1,293 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.19.4 +// source: test/test.proto + +package test + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type NinOptNative struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Field1 *float64 `protobuf:"fixed64,1,opt,name=Field1,proto3,oneof" json:"Field1,omitempty"` + Field2 *float32 `protobuf:"fixed32,2,opt,name=Field2,proto3,oneof" json:"Field2,omitempty"` + Field3 *int32 `protobuf:"varint,3,opt,name=Field3,proto3,oneof" json:"Field3,omitempty"` + Field4 *int64 `protobuf:"varint,4,opt,name=Field4,proto3,oneof" json:"Field4,omitempty"` + Field5 *uint32 `protobuf:"varint,5,opt,name=Field5,proto3,oneof" json:"Field5,omitempty"` + Field6 *uint64 `protobuf:"varint,6,opt,name=Field6,proto3,oneof" json:"Field6,omitempty"` + Field7 *int32 `protobuf:"zigzag32,7,opt,name=Field7,proto3,oneof" json:"Field7,omitempty"` + Field8 *int64 `protobuf:"zigzag64,8,opt,name=Field8,proto3,oneof" json:"Field8,omitempty"` + Field9 *uint32 `protobuf:"fixed32,9,opt,name=Field9,proto3,oneof" json:"Field9,omitempty"` + Field10 *int32 `protobuf:"fixed32,10,opt,name=Field10,proto3,oneof" json:"Field10,omitempty"` + Field11 *uint64 `protobuf:"fixed64,11,opt,name=Field11,proto3,oneof" json:"Field11,omitempty"` + Field12 *int64 `protobuf:"fixed64,12,opt,name=Field12,proto3,oneof" json:"Field12,omitempty"` + Field13 *bool `protobuf:"varint,13,opt,name=Field13,proto3,oneof" json:"Field13,omitempty"` + Field14 *string `protobuf:"bytes,14,opt,name=Field14,proto3,oneof" json:"Field14,omitempty"` + Field15 []byte `protobuf:"bytes,15,opt,name=Field15,proto3,oneof" json:"Field15,omitempty"` +} + +func (x *NinOptNative) Reset() { + *x = NinOptNative{} + if protoimpl.UnsafeEnabled { + mi := &file_test_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NinOptNative) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NinOptNative) ProtoMessage() {} + +func (x *NinOptNative) ProtoReflect() protoreflect.Message { + mi := &file_test_test_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NinOptNative.ProtoReflect.Descriptor instead. +func (*NinOptNative) Descriptor() ([]byte, []int) { + return file_test_test_proto_rawDescGZIP(), []int{0} +} + +func (x *NinOptNative) GetField1() float64 { + if x != nil && x.Field1 != nil { + return *x.Field1 + } + return 0 +} + +func (x *NinOptNative) GetField2() float32 { + if x != nil && x.Field2 != nil { + return *x.Field2 + } + return 0 +} + +func (x *NinOptNative) GetField3() int32 { + if x != nil && x.Field3 != nil { + return *x.Field3 + } + return 0 +} + +func (x *NinOptNative) GetField4() int64 { + if x != nil && x.Field4 != nil { + return *x.Field4 + } + return 0 +} + +func (x *NinOptNative) GetField5() uint32 { + if x != nil && x.Field5 != nil { + return *x.Field5 + } + return 0 +} + +func (x *NinOptNative) GetField6() uint64 { + if x != nil && x.Field6 != nil { + return *x.Field6 + } + return 0 +} + +func (x *NinOptNative) GetField7() int32 { + if x != nil && x.Field7 != nil { + return *x.Field7 + } + return 0 +} + +func (x *NinOptNative) GetField8() int64 { + if x != nil && x.Field8 != nil { + return *x.Field8 + } + return 0 +} + +func (x *NinOptNative) GetField9() uint32 { + if x != nil && x.Field9 != nil { + return *x.Field9 + } + return 0 +} + +func (x *NinOptNative) GetField10() int32 { + if x != nil && x.Field10 != nil { + return *x.Field10 + } + return 0 +} + +func (x *NinOptNative) GetField11() uint64 { + if x != nil && x.Field11 != nil { + return *x.Field11 + } + return 0 +} + +func (x *NinOptNative) GetField12() int64 { + if x != nil && x.Field12 != nil { + return *x.Field12 + } + return 0 +} + +func (x *NinOptNative) GetField13() bool { + if x != nil && x.Field13 != nil { + return *x.Field13 + } + return false +} + +func (x *NinOptNative) GetField14() string { + if x != nil && x.Field14 != nil { + return *x.Field14 + } + return "" +} + +func (x *NinOptNative) GetField15() []byte { + if x != nil { + return x.Field15 + } + return nil +} + +var File_test_test_proto protoreflect.FileDescriptor + +var file_test_test_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x04, 0x74, 0x65, 0x73, 0x74, 0x22, 0xf8, 0x04, 0x0a, 0x0c, 0x4e, 0x69, 0x6e, 0x4f, + 0x70, 0x74, 0x4e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x12, 0x1b, 0x0a, 0x06, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x06, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x31, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x32, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x02, 0x48, 0x01, 0x52, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x32, 0x88, + 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x33, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x05, 0x48, 0x02, 0x52, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x33, 0x88, 0x01, 0x01, 0x12, + 0x1b, 0x0a, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x48, + 0x03, 0x52, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x34, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x35, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x48, 0x04, 0x52, 0x06, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x35, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x36, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x48, 0x05, 0x52, 0x06, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x36, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x37, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x11, 0x48, 0x06, 0x52, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x37, + 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x38, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x12, 0x48, 0x07, 0x52, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x38, 0x88, 0x01, 0x01, + 0x12, 0x1b, 0x0a, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x39, 0x18, 0x09, 0x20, 0x01, 0x28, 0x07, + 0x48, 0x08, 0x52, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x39, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, + 0x07, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x31, 0x30, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0f, 0x48, 0x09, + 0x52, 0x07, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x31, 0x30, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x31, 0x31, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x06, 0x48, 0x0a, 0x52, + 0x07, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x31, 0x31, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x31, 0x32, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x10, 0x48, 0x0b, 0x52, 0x07, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x31, 0x32, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x31, 0x33, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x48, 0x0c, 0x52, 0x07, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x31, 0x33, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x31, 0x34, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x48, 0x0d, 0x52, 0x07, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x31, 0x34, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x31, 0x35, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x0e, 0x52, 0x07, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x31, 0x35, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x31, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x32, 0x42, 0x09, 0x0a, + 0x07, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x33, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x34, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x35, 0x42, 0x09, + 0x0a, 0x07, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x36, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x37, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x38, 0x42, + 0x09, 0x0a, 0x07, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x39, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x31, 0x30, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x31, 0x31, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x31, 0x32, 0x42, 0x0a, + 0x0a, 0x08, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x31, 0x33, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x31, 0x34, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x31, 0x35, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6c, 0x69, 0x62, 0x70, 0x32, 0x70, 0x2f, 0x67, 0x6f, 0x2d, 0x6d, 0x73, 0x67, 0x69, 0x6f, + 0x2f, 0x74, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_test_test_proto_rawDescOnce sync.Once + file_test_test_proto_rawDescData = file_test_test_proto_rawDesc +) + +func file_test_test_proto_rawDescGZIP() []byte { + file_test_test_proto_rawDescOnce.Do(func() { + file_test_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_test_proto_rawDescData) + }) + return file_test_test_proto_rawDescData +} + +var file_test_test_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_test_test_proto_goTypes = []interface{}{ + (*NinOptNative)(nil), // 0: test.NinOptNative +} +var file_test_test_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_test_test_proto_init() } +func file_test_test_proto_init() { + if File_test_test_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_test_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NinOptNative); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_test_test_proto_msgTypes[0].OneofWrappers = []interface{}{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_test_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_test_test_proto_goTypes, + DependencyIndexes: file_test_test_proto_depIdxs, + MessageInfos: file_test_test_proto_msgTypes, + }.Build() + File_test_test_proto = out.File + file_test_test_proto_rawDesc = nil + file_test_test_proto_goTypes = nil + file_test_test_proto_depIdxs = nil +} diff --git a/test/test.proto b/test/test.proto new file mode 100644 index 0000000..9772c91 --- /dev/null +++ b/test/test.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package test; +option go_package = "github.com/libp2p/go-msgio/test"; + +message NinOptNative { + optional double Field1 = 1; + optional float Field2 = 2; + optional int32 Field3 = 3; + optional int64 Field4 = 4; + optional uint32 Field5 = 5; + optional uint64 Field6 = 6; + optional sint32 Field7 = 7; + optional sint64 Field8 = 8; + optional fixed32 Field9 = 9; + optional sfixed32 Field10 = 10; + optional fixed64 Field11 = 11; + optional sfixed64 Field12 = 12; + optional bool Field13 = 13; + optional string Field14 = 14; + optional bytes Field15 = 15; +}