You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: equal.go
    path of file: ./repos/kubeedge/vendor/github.com/google/cel-go/common/types/pb
    
    the code of the file until where you have to start completion: // Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package pb

import (
	"bytes"
	"reflect"

	"google.golang.org/protobuf/encoding/protowire"
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/reflect/protoreflect"

	anypb "google.golang.org/protobuf/types/known/anypb"
)

// Equal returns whether two proto.Message instances are equal using the following criteria:
//
//   - Messages must share the same instance of the type descriptor
//   - Known set fields are compared using semantics equality
//     - Bytes are compared using bytes.Equal
//     - Scalar values are compared with operator ==
//     - List and map types are equal if they have the same length and all elements are equal
//     - Messages are equal if they share the same descriptor and all set fields are equal
//   - Unknown fields are compared using byte equality
//   - NaN values are not equal to each other
//   - google.protobuf.Any values are unpacked before comparison
//   - If the type descriptor for a protobuf.Any cannot be found, byte equality is used rather than
//     semantic equality.
//
// This method of proto equality mirrors the beh
    
func equalMessage(mx, my protoreflect.Message) bool {
	// Note, the original proto.Equal upon which this implementation is based does not specifically handle the
	// case when both messages are invalid. It is assumed that the descriptors will be equal and that byte-wise
	// comparison will be used, though the semantics of validity are neither clear, nor promised within the
	//  proto.Equal implementation.
	if mx.IsValid() != my.IsValid() || mx.Descriptor() != my.Descriptor() {
		return false
	}

	// This is an innovation on the default proto.Equal where protobuf.Any values are unpacked before comparison
	// as otherwise the Any values are compared by bytes rather than structurally.
	if isAny(mx) && isAny(my) {
		ax := mx.Interface().(*anypb.Any)
		ay := my.Interface().(*anypb.Any)
		// If the values are not the same type url, return false.
		if ax.GetTypeUrl() != ay.GetTypeUrl() {
			return false
		}
		// If the values are byte equal, then return true.
		if bytes.Equal(ax.GetValue(), ay.GetValue()) {
			return true
		}
		// Otherwise fall through to the semantic comparison of the any values.
		x, err := ax.UnmarshalNew()
		if err != nil {
			return false
		}
		y, err := ay.UnmarshalNew()
		if err != nil {
			return false
		}
		// Recursively compare the unwrapped messages to ensure nested Any values are unwrapped accordingly.
		return equalMessage(x.ProtoReflect(), y.ProtoReflect())
	}

	// Walk the set fields to determine field-wise equality
	nx := 0
	equal := true
	mx.Range(func(fd protoreflect.FieldDescriptor, vx protoreflect.Value) bool {
		nx++
		equal = my.Has(fd) && equalField(fd, vx, my.Get(fd))
		return equal
	})
	if !equal {
		return false
	}
	// Establish the count of set fields on message y
	ny := 0
	my.Range(func(protoreflect.FieldDescriptor, protoreflect.Value) bool {
		ny++
		return true
	})
	// If the number of set fields is not equal return false.
	if nx != ny {
		return false
	}

	return equalUnknown(mx.GetUnknown(), my.GetUnknown())
}