wrapcheck
wrapcheck copied to clipboard
Why does the isError function not determine whether the passed type implements the interface, but instead uses whether the type is error?
// isError returns whether or not the provided type implements the error interface func isError(typ types.Type) bool { if typ == nil { return false } // 获取 error 接口的类型 errorInterface := types.Universe.Lookup("error").Type().Underlying().(*types.Interface) // 判断 typ 是否实现了 error 接口 return types.Implements(typ, errorInterface) }
Sorry, but you're going to need to reformulate the question with more context in order to get a good response. Right now, I don't know what you're asking.