We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It seems like extensions are not encoded to the wire (but what's interesting - decoded from the wire).
proto
syntax = "proto2"; option go_package = "protobuf-benchmarks/pb/google/test/test;testpb"; message MyMessage { optional int32 foo = 1; extensions 100 to max; } extend MyMessage { optional int32 bar = 100; }
Test
import ( ... "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func Test(t *testing.T) { t.Run("encoding", func(t *testing.T) { m := &prototestpb.MyMessage{Foo: proto.Int32(1)} proto.SetExtension(m, prototestpb.E_Bar, int32(2)) b, err := m.MarshalVT() require.NoError(t, err) m2 := &prototestpb.MyMessage{} err = m2.UnmarshalVT(b) require.NoError(t, err) assert.True(t, proto.HasExtension(m2, prototestpb.E_Bar)) // Fail, Should be true }) t.Run("decoding", func(t *testing.T) { m := &prototestpb.MyMessage{Foo: proto.Int32(1)} proto.SetExtension(m, prototestpb.E_Bar, int32(2)) b, err := proto.Marshal(m) // Use native proto for marshalling require.NoError(t, err) m2 := &prototestpb.MyMessage{} err = m2.UnmarshalVT(b) require.NoError(t, err) assert.True(t, proto.HasExtension(m2, prototestpb.E_Bar)) // Pass }) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
It seems like extensions are not encoded to the wire (but what's interesting - decoded from the wire).
proto
Test
The text was updated successfully, but these errors were encountered: