encoding/prototext: add MarshalOptions.EmitUnknown
This changes text marshaling to avoid unknown fields by default
and instead adds an option so that unknown fields be emitted.
This ensures that the default marshal/unknown can round-trip.
Change-Id: I85c84ba6ab7916d538ec6bfd4e9d399a8fcba14e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/195778
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/proto/decode_test.go b/proto/decode_test.go
index c8d34c7..c696778 100644
--- a/proto/decode_test.go
+++ b/proto/decode_test.go
@@ -1748,6 +1748,10 @@
}
func marshalText(m proto.Message) string {
- b, _ := prototext.MarshalOptions{Indent: "\t", AllowPartial: true}.Marshal(m)
+ b, _ := prototext.MarshalOptions{
+ AllowPartial: true,
+ EmitUnknown: true,
+ Indent: "\t",
+ }.Marshal(m)
return string(b)
}