prototext

package
v0.0.0-...-ce5093a Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompactText

func CompactText(w io.Writer, m Message) error

CompactText writes the compact proto text format of m to w.

func CompactTextString

func CompactTextString(m Message) string

CompactTextString returns a compact proto text formatted string of m.

func MarshalText

func MarshalText(w io.Writer, m Message) error

MarshalText writes the proto text format of m to w.

func MarshalTextString

func MarshalTextString(m Message) string

MarshalTextString returns a proto text formatted string of m.

func MessageReflect

func MessageReflect(m Message) protoreflect.Message

MessageReflect returns a reflective view for a message. It returns nil if m is nil.

Types

type Message

type Message = protoiface.MessageV1

Message is a protocol buffer message.

This is the v1 version of the message interface and is marginally better than an empty interface as it lacks any method to programatically interact with the contents of the message.

A v2 message is declared in "google.golang.org/protobuf/proto".Message and exposes protobuf reflection as a first-class feature of the interface.

To convert a v1 message to a v2 message, use the MessageV2 function. To convert a v2 message to a v1 message, use the MessageV1 function.

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithStringLimit

func WithStringLimit(limit int) Option

type TextMarshaler

type TextMarshaler struct {
	Compact   bool // use compact text format (one line)
	ExpandAny bool // expand google.protobuf.Any messages of known types
	// contains filtered or unexported fields
}

TextMarshaler is a configurable text format marshaler.

func NewMarshaler

func NewMarshaler(opts ...Option) TextMarshaler

func (*TextMarshaler) Marshal

func (tm *TextMarshaler) Marshal(w io.Writer, m Message) error

Marshal writes the proto text format of m to w.

func (*TextMarshaler) Text

func (tm *TextMarshaler) Text(m Message) string

Text returns a proto text formatted string of m.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL