上下文:我正在尝试将类型转换为类型,但遇到编译错误。Go抱怨说类型转换是不可能的,但没有解释为什么。最小重现如下所示:func(*interface{}) boolfunc(*string) bool
法典:
type strIterFn func(*string) bool
func someFactory (_ []interface{}) func(*interface{}) bool {
return func(_ *interface{}) bool { return true }
}
func main() {
strs := []interface{}{"hello", "world"}
strIterFn(someFactory(strs)) // --> this line fails to compile
}
游乐场: https://play.golang.org/p/oOSy50j_tKw
守候你守候我
相关分类