Documentation
¶
Index ¶
- func Clone[M proto.Message](m M) M
- func CompactTextString(m proto.Message) string
- func Equal(x, y proto.Message) bool
- func EqualList[M proto.Message](a, b []M) bool
- func Marshal(m proto.Message) ([]byte, error)
- func MarshalTextString(m proto.Message) string
- func Unmarshal[M any, T interface{ ... }](buf []byte) (*M, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
Clone returns a deep copy of m. If the top-level message is invalid, it returns an invalid message as well.
func CompactTextString ¶
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 ¶
Equal reports whether two messages are equal, by recursively comparing the fields of the message.
func MarshalTextString ¶
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 ¶
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.