Skip to content

Commit e1cc4b5

Browse files
committed
proto, internal/proto: fix tests broken by latest v2 module
Correct a failure in (un)marshaling extensions caused by expecting a *[]T where we now use a []T. Include unknown fields in text marshal output. Change-Id: Ica1ecab1f0768a1208b00915884ccd8026cc53a8 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/204803 Reviewed-by: Joe Tsai <[email protected]>
1 parent ba00afd commit e1cc4b5

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

internal/proto/text.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error {
5151
}
5252
mo := prototext.MarshalOptions{
5353
AllowPartial: true,
54+
EmitUnknown: true,
5455
Indent: ind,
5556
}
5657
if !tm.ExpandAny {

proto/table_marshal.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,18 +393,12 @@ func (u *marshalInfo) getExtElemInfo(desc *ExtensionDesc) *marshalElemInfo {
393393
t = t.Elem()
394394
}
395395
sizer, marshaler := typeMarshaler(t, tags, false, false)
396-
var deref bool
397-
if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 {
398-
t = reflect.PtrTo(t)
399-
deref = true
400-
}
401396
e = &marshalElemInfo{
402397
wiretag: uint64(tag)<<3 | wt,
403398
tagsize: SizeVarint(uint64(tag) << 3),
404399
sizer: sizer,
405400
marshaler: marshaler,
406401
isptr: t.Kind() == reflect.Ptr,
407-
deref: deref,
408402
}
409403

410404
// update cache

0 commit comments

Comments
 (0)