equality

package
v1.7.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepEqual

func DeepEqual(x, y any) bool

DeepEqual is a wrapper around reflect.DeepEqual, which first checks if arguments implement CustomEquality. If they do, their Equals method is used for comparison instead of reflect.DeepEqual. For simplicity, DeepEqual requires x and y to be of the same type before calling CustomEquality.Equals. NOTE: structs, slices, maps and arrays that contain a mix of values implementing CustomEquality and not implementing it are not supported. Unexported fields are not supported either. In those cases, implement CustomEquality on higher level of your object hierarchy.

Types

type CustomEquality

type CustomEquality interface {
	Equals(other any) bool
}

CustomEquality allows to define custom Equals implementation. This can be used, for example, with exported types, so that the Runtime can short-circuit propagating updates when it is not necessary. If a struct is passed to DeepEqual, the `other` supplied to Equals will be a pointer. See tests for reference.

Jump to

Keyboard shortcuts

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