1 // Package equaler gives a simple interface to compare objects of arbitrary types. 2 package equaler // import "vimagination.zapto.org/equaler" 3 4 // Equaler is a simple interface that is used to determing the equality of two 5 // variables 6 type Equaler interface { 7 Equal(interface{}) bool 8 } 9 10 type eFalse struct{} 11 12 func (eFalse) Equal(interface{}) bool { 13 return false 14 } 15 16 func (eFalse) String() string { 17 return "Equaler - False" 18 } 19 20 type eThis struct{} 21 22 func (eThis) Equal(e interface{}) bool { 23 _, ok := e.(eThis) 24 return ok 25 } 26 27 func (eThis) String() string { 28 return "Equaler - This" 29 } 30 31 var ( 32 // EFalse represents an Equaler that never matches, even against itself 33 EFalse Equaler = eFalse{} 34 // EThis represents an Equaler that only and always matches itself 35 EThis Equaler = eThis{} 36 )