protobuf: google.golang.org/protobuf/encoding/prototext Index | Files

package prototext

import "google.golang.org/protobuf/encoding/prototext"

Package prototext marshals and unmarshals protocol buffer messages as the textproto format.

Index

Package Files

decode.go doc.go encode.go

func Format Uses

func Format(m proto.Message) string

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.

func Marshal Uses

func Marshal(m proto.Message) ([]byte, error)

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 Unmarshal Uses

func Unmarshal(b []byte, m proto.Message) error

Unmarshal reads the given []byte into the given proto.Message.

type MarshalOptions Uses

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 Uses

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 Uses

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.

type UnmarshalOptions Uses

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.

func (UnmarshalOptions) Unmarshal Uses

func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error

Unmarshal reads the given []byte and populates the given proto.Message using options in UnmarshalOptions object.

Package prototext imports 16 packages (graph) and is imported by 38 packages. Updated 2020-09-09. Refresh now. Tools for package owners.