# README
The deriveEqual function is a faster alternative to reflect.DeepEqual.
Given the following input:
package equal
type MyStruct struct {
Int64 int64
StringPtr *string
Foo *Foo
}
func (this *MyStruct) Equal(that *MyStruct) bool {
return deriveEqual(this, that)
}
type Foo struct {
Name string
other string
}
func (this *Foo) Equal(that *Foo) bool {
return this.Name == that.Name
}
goderive will generate the following code:
// Code generated by goderive DO NOT EDIT.
package equal
// deriveEqual returns whether this and that are equal.
func deriveEqual(this, that *MyStruct) bool {
return (this == nil && that == nil) ||
this != nil && that != nil &&
this.Int64 == that.Int64 &&
((this.StringPtr == nil && that.StringPtr == nil) || (this.StringPtr != nil && that.StringPtr != nil && *(this.StringPtr) == *(that.StringPtr))) &&
this.Foo.Equal(that.Foo)
}