prototext
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package prototext marshals and unmarshals protocol buffer messages as thetextproto format.
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcFormat¶
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. Its output will change acrossdifferent builds of your program, even when using the same version of theprotobuf module.
funcMarshal¶
Marshal writes the givenproto.Message in textproto format using defaultoptions. Do not depend on the output being stable. Its output will changeacross different builds of your program, even when using the same version ofthe protobuf module.
Types¶
typeMarshalOptions¶
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.Multilinebool// 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.Indentstring// EmitASCII specifies whether to format strings and bytes as ASCII only// as opposed to using UTF-8 encoding when possible.EmitASCIIbool// 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.AllowPartialbool// 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.EmitUnknownbool// Resolver is used for looking up types when expanding google.protobuf.Any// messages. If nil, this defaults to using protoregistry.GlobalTypes.Resolver interface {protoregistry.ExtensionTypeResolverprotoregistry.MessageTypeResolver}// contains filtered or unexported fields}MarshalOptions is a configurable text format marshaler.
func (MarshalOptions)Format¶
func (oMarshalOptions) Format(mproto.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. Its output will change acrossdifferent builds of your program, even when using the same version of theprotobuf module.
func (MarshalOptions)Marshal¶
func (oMarshalOptions) Marshal(mproto.Message) ([]byte,error)
Marshal writes the givenproto.Message in textproto format using options inMarshalOptions object. Do not depend on the output being stable. Its outputwill change across different builds of your program, even when using thesame version of the protobuf module.
func (MarshalOptions)MarshalAppend¶added inv1.31.0
MarshalAppend appends the textproto format encoding of m to b,returning the result.
typeUnmarshalOptions¶
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.AllowPartialbool// 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.DiscardUnknownbool// 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.MessageTypeResolverprotoregistry.ExtensionTypeResolver}}UnmarshalOptions is a configurable textproto format unmarshaler.
func (UnmarshalOptions)Unmarshal¶
func (oUnmarshalOptions) Unmarshal(b []byte, mproto.Message)error
Unmarshal reads the given []byte and populates the givenproto.Messageusing options in the UnmarshalOptions object.The provided message must be mutable (e.g., a non-nil pointer to a message).