protox

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone[M proto.Message](m M) M

Clone returns a deep copy of m. If the top-level message is invalid, it returns an invalid message as well.

func CompactTextString

func CompactTextString(m proto.Message) string

CompactTextString returns a compact, single-line text representation of the given proto.Message. This format omits unnecessary whitespace and is suitable for logging or debugging where space is a concern.

func Equal

func Equal(x, y proto.Message) bool

Equal reports whether two messages are equal, by recursively comparing the fields of the message.

func EqualList

func EqualList[M proto.Message](a, b []M) bool

EqualList compares two message slices with proto.Equal. Convenience method.

func Marshal

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

Marshal returns the wire-format encoding of m.

func MarshalTextString

func MarshalTextString(m proto.Message) string

MarshalTextString returns a multiline, human-readable text representation of the given proto.Message. This format includes indentation and line breaks, making it easier to read for humans.

func Unmarshal

func Unmarshal[M any, T interface {
	*M
	proto.Message
}](buf []byte) (*M, error)

Unmarshal is a generic, direct-style wrapper for proto.Unmarshal that returns the message value directly.

Type Parameters:

M - the concrete protobuf message type
T - an interface to satisfy type system, should not be provided

This function differs from the standard proto.Unmarshal in that it does not require the caller to provide a pointer to the message. Instead, it creates a new instance of the message type, unmarshals the data into it, and returns a pointer to the message.

Example usage:

msg, err := protox.Unmarshal[com.example.v1.MyMessage](data)
// msg is of type *com.example.v1.MyMessage

Types

This section is empty.

Jump to

Keyboard shortcuts

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