1 // Copyright 2024 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package proto_test 6 7 import ( 8 "google.golang.org/protobuf/proto" 9 ) 10 11 // Checking if [Size] returns 0 is an easy way to recognize empty messages: 12 func ExampleSize() { 13 var m proto.Message 14 if proto.Size(m) == 0 { 15 // No fields set (or, in proto3, all fields matching the default); 16 // skip processing this message, or return an error, or similar. 17 } 18 } 19