equal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package equal provides a deep equivalence relation for arbitrary values.

Example (Equal)
fmt.Println(Equal([]int{1, 2, 3}, []int{1, 2, 3}))        // "true"
fmt.Println(Equal([]string{"foo"}, []string{"bar"}))      // "false"
fmt.Println(Equal([]string(nil), []string{}))             // "true"
fmt.Println(Equal(map[string]int(nil), map[string]int{})) // "true"
Output:

true
false
true
true
Example (EqualCycle)
// Circular linked lists a -> b -> a and c -> c.
type link struct {
	value string
	tail  *link
}
a, b, c := &link{value: "a"}, &link{value: "b"}, &link{value: "c"}
a.tail, b.tail, c.tail = b, a, c
fmt.Println(Equal(a, a)) // "true"
fmt.Println(Equal(b, b)) // "true"
fmt.Println(Equal(c, c)) // "true"
fmt.Println(Equal(a, b)) // "false"
fmt.Println(Equal(a, c)) // "false"
Output:

true
true
true
false
false

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(x, y interface{}) bool

Equal reports whether x and y deeply equal. Map keys are always compared with ==, not deeply. (This matter for keys containing pointers or interfaces.)

Types

This section is empty.

Jump to

Keyboard shortcuts

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