anypb

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 4 Imported by: 0

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.

Jump to

Keyboard shortcuts

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