MCPcopy
hub / github.com/grpc/grpc-go / MarshalAny

Function MarshalAny

internal/testutils/marshal_any.go:29–37  ·  view source on GitHub ↗

MarshalAny is a convenience function to marshal protobuf messages into any protos. function will fail the test with a fatal error if the marshaling fails.

(t *testing.T, m proto.Message)

Source from the content-addressed store, hash-verified

27// MarshalAny is a convenience function to marshal protobuf messages into any
28// protos. function will fail the test with a fatal error if the marshaling fails.
29func MarshalAny(t *testing.T, m proto.Message) *anypb.Any {
30 t.Helper()
31
32 a, err := anypb.New(m)
33 if err != nil {
34 t.Fatalf("Failed to marshal proto %+v into an Any: %v", m, err)
35 }
36 return a
37}

Calls 1

FatalfMethod · 0.65