encoding/textpb: add AllowPartial option to MarshalOptions and UnmarshalOptions
Provide AllowPartial option to accept messages with missing required
field during marshaling and unmarshaling.
Change-Id: Ia23783870a8125633f8ddc0b686984b4c5ca15ba
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/169500
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/export.go b/internal/impl/export.go
index 801457b..5dae010 100644
--- a/internal/impl/export.go
+++ b/internal/impl/export.go
@@ -91,6 +91,6 @@
// MessageStringOf returns the message value as a string,
// which is the message serialized in the protobuf text format.
func (Export) MessageStringOf(m pref.ProtoMessage) string {
- b, _ := textpb.Marshal(m)
+ b, _ := textpb.MarshalOptions{AllowPartial: true}.Marshal(m)
return string(b)
}