MCPcopy
hub / github.com/protocolbuffers/protobuf-go / ExampleSize

Function ExampleSize

proto/size_test.go:17–23  ·  view source on GitHub ↗

Checking if [Size] returns 0 is an easy way to recognize empty messages:

()

Source from the content-addressed store, hash-verified

15
16// Checking if [Size] returns 0 is an easy way to recognize empty messages:
17func ExampleSize() {
18 var m proto.Message
19 if proto.Size(m) == 0 {
20 // No fields set (or, in proto3, all fields matching the default);
21 // skip processing this message, or return an error, or similar.
22 }
23}
24
25func TestSizeAnyNonNilButEmpty(t *testing.T) {
26 ne := &anypb.Any{

Callers

nothing calls this directly

Calls 1

SizeFunction · 0.92

Tested by

no test coverage detected