Is there a better way of doing this? I need to know if the type of v is the built-in "error" type. I feel like there should be a neater way of doing this:
import (
"go/ast"
"go/types"
)
func IsError(v ast.Expr, info types.Info) bool {
t := info.Types[v]
return t.Type.String() == "error" &&
t.Type.Underlying().String() == "interface{Error() string}"
}