encoding/prototext: document unstable marshal output

Fixes golang/protobuf#920.

Change-Id: I04c12de9a662eb67994fc7eeceee1af4a9efee55
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/188937
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
Herbie Ong 2019-08-05 11:40:38 +08:00
parent 582ab3de42
commit 9e356dea53
2 changed files with 7 additions and 3 deletions

View File

@ -20,7 +20,7 @@ import (
)
// Marshal writes the given proto.Message in JSON format using default options.
// Do not depend on the output of being stable. It may change over time across
// Do not depend on the output being stable. It may change over time across
// different versions of the program.
func Marshal(m proto.Message) ([]byte, error) {
return MarshalOptions{}.Marshal(m)

View File

@ -22,7 +22,9 @@ import (
"google.golang.org/protobuf/reflect/protoregistry"
)
// Marshal writes the given proto.Message in textproto format using default options.
// Marshal writes the given proto.Message in textproto format using default
// options. Do not depend on the output being stable. It may change over time
// across different versions of the program.
func Marshal(m proto.Message) ([]byte, error) {
return MarshalOptions{}.Marshal(m)
}
@ -49,7 +51,9 @@ type MarshalOptions struct {
}
}
// Marshal writes the given proto.Message in textproto format using options in MarshalOptions object.
// Marshal writes the given proto.Message in textproto format using options in
// MarshalOptions object. Do not depend on the output being stable. It may
// change over time across different versions of the program.
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
if o.Resolver == nil {
o.Resolver = protoregistry.GlobalTypes