Skip to content

Why does the isError function not determine whether the passed type implements the interface, but instead uses whether the type is error? #63

@heucoder

Description

@heucoder

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions