wrapcheck icon indicating copy to clipboard operation
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?

Open heucoder opened this issue 5 months ago • 1 comments

// 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) }

heucoder avatar Jul 16 '25 11:07 heucoder

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.

tomarrell avatar Jul 16 '25 15:07 tomarrell