Documentation
¶
Overview ¶
Package anypb provides helpers for working with protobuf Any messages. It lives outside any transport package so REST, gRPC and message-broker consumers can all pull from one place without importing transport code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidProtoType = errors.New("message is not valid type")
ErrInvalidProtoType is returned when the Any message does not contain the expected proto type.
Functions ¶
func AnyToProto ¶
func AnyToProto[P protoreflect.ProtoMessage](a *anypb.Any) (P, error)
AnyToProto unmarshals a protobuf Any message into the specified proto type.
The type parameter P must be a pointer to a proto message (e.g. *pb.User).
Example:
anyMsg := &anypb.Any{...}
user, err := anypb.AnyToProto[*pb.User](anyMsg)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.