Movatterモバイル変換


[0]ホーム

URL:


prototext

package
v1.36.11Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License:BSD-3-ClauseImports:16Imported by:987

Details

Repository

github.com/protocolbuffers/protobuf-go

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

func Format(mproto.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. Its output will change acrossdifferent builds of your program, even when using the same version of theprotobuf module.

funcMarshal

func Marshal(mproto.Message) ([]byte,error)

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.

funcUnmarshal

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

Unmarshal reads the given []byte into the givenproto.Message.The provided message must be mutable (e.g., a non-nil pointer to a message).

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

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)MarshalAppendadded inv1.31.0

func (oMarshalOptions) MarshalAppend(b []byte, mproto.Message) ([]byte,error)

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).

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp