Documentation ¶
Overview ¶
Package prototext marshals and unmarshals protocol buffer messages as the textproto format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Format ¶
Format formats the message as a multiline string. This function is only intended for human consumption and ignores errors. Do not depend on the output being stable. It may change over time across different versions of the program.
Types ¶
type MarshalOptions ¶
type MarshalOptions struct { pragma.NoUnkeyedLiterals // Multiline specifies whether the marshaler should format the output in // indented-form with every textual element on a new line. // If Indent is an empty string, then an arbitrary indent is chosen. Multiline bool // Indent specifies the set of indentation characters to use in a multiline // formatted output such that every entry is preceded by Indent and // terminated by a newline. If non-empty, then Multiline is treated as true. // Indent can only be composed of space or tab characters. Indent string // EmitASCII specifies whether to format strings and bytes as ASCII only // as opposed to using UTF-8 encoding when possible. EmitASCII bool // AllowPartial allows messages that have missing required fields to marshal // without returning an error. If AllowPartial is false (the default), // Marshal will return error if there are any missing required fields. AllowPartial bool // EmitUnknown specifies whether to emit unknown fields in the output. // If specified, the unmarshaler may be unable to parse the output. // The default is to exclude unknown fields. EmitUnknown bool // Resolver is used for looking up types when expanding google.protobuf.Any // messages. If nil, this defaults to using protoregistry.GlobalTypes. Resolver interface { protoregistry.ExtensionTypeResolver protoregistry.MessageTypeResolver } // contains filtered or unexported fields }
MarshalOptions is a configurable text format marshaler.
func (MarshalOptions) Format ¶
func (o MarshalOptions) Format(m proto.Message) string
Format formats the message as a string. This method is only intended for human consumption and ignores errors. Do not depend on the output being stable. It may change over time across different versions of the program.
func (MarshalOptions) Marshal ¶
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error)
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 (MarshalOptions) MarshalAppend ¶
MarshalAppend appends the textproto format encoding of m to b, returning the result.
type UnmarshalOptions ¶
type UnmarshalOptions struct { pragma.NoUnkeyedLiterals // AllowPartial accepts input for messages that will result in missing // required fields. If AllowPartial is false (the default), Unmarshal will // return error if there are any missing required fields. AllowPartial bool // DiscardUnknown specifies whether to ignore unknown fields when parsing. // An unknown field is any field whose field name or field number does not // resolve to any known or extension field in the message. // By default, unmarshal rejects unknown fields as an error. DiscardUnknown bool // Resolver is used for looking up types when unmarshaling // google.protobuf.Any messages or extension fields. // If nil, this defaults to using protoregistry.GlobalTypes. Resolver interface { protoregistry.MessageTypeResolver protoregistry.ExtensionTypeResolver } }
UnmarshalOptions is a configurable textproto format unmarshaler.