Per examples (e.g. getting panic() argument in defer function in GO lang) I've seen, I'm expecting this to work, but it isn't. When forcing an error, the err
return string remains blank, although printing the err string shows the expected error.
I'm sure I'm missing something obvious, but can't find it. A little help?
// expected error example:
// chk, err := equal("a", map[string]string{"a"})
//
func Equal(a interface{}, b interface{}) (check bool, err string) {
defer func() {
if catch := recover(); catch != nil {
check = false
// this prints
fmt.Printf("%v
", catch)
err = fmt.Sprint(catch)
}
}()
return a == b, ""
}
BTW:
go version go1.2.1 linux/amd64