I am doing some testing and trying to test for equality of some function types. I have https://play.golang.org/p/GeE_YJF5lz :
package main
import (
"fmt"
"reflect"
)
type myStruct struct {
f []someFunc
}
type someFunc func(a string) bool
var sf1 someFunc = func(a string) bool {
return true
}
var sf2 someFunc = func(a string) bool {
return false
}
func main() {
a := []someFunc{sf1, sf2}
b := []someFunc{sf1, sf2}
fmt.Println(reflect.DeepEqual(a, b)) // false
m := &myStruct{
f: []someFunc{sf1, sf2},
}
n := &myStruct{
f: []someFunc{sf1, sf2},
}
fmt.Println(reflect.DeepEqual(m, n)) // false
}
I haven't been able to find anything in the docs about comparing functions and know I must be missing something important as to why reflect.DeepEqual doesn't work for them properly.