cmp

package
v0.0.0-...-93a508a Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cmp provides utility functions to compare two values

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(list, contains interface{}, comparer Comparer) (err error)

Contains checks if the given list contains the element using the comparer.

Types

type Comparer

type Comparer interface {
	// Eq will compare the interface values of 'a' and 'b' for equality.
	Eq(a, b interface{}) error
}

Comparer is used to compare two values. An error means the fields are either not equal or that an error occurred in comparing them.

type DeepEqualComparer

type DeepEqualComparer struct{}

DeepEqualComparer compares two objects using the deep equal operators.

func (*DeepEqualComparer) Eq

func (de *DeepEqualComparer) Eq(a, b interface{}) error

Eq will compare using the reflect deep equal function.

type DefinedComparer

type DefinedComparer struct{}

DefinedComparer tells whether one interface contains the defined fields of another. This operator relies on `omitempty` json tags being present in fields that shouldn't be compared when empty.

func (*DefinedComparer) Eq

func (dc *DefinedComparer) Eq(a, b interface{}) error

Eq will tell whether the fields and values defined in 'a' are present in 'b'. An error mean the values are either not equal or that an error occurred in comparing them.

type IterableMessage

type IterableMessage interface {
	proto.Message
	Contains(a interface{}, comparer Comparer) error
}

IterableMessage is an iterable proto message type.

Directories

Path Synopsis
Package strings provides string related utilities for testing purposes.
Package strings provides string related utilities for testing purposes.

Jump to

Keyboard shortcuts

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