错误示例@play.golang.org:http ://play.golang.org/p/GRoqRHnTj6
即使接口完全为空,以下代码也会返回“prog.go:16: cannot use NewMyGame (type func() MyGame) as type func() Playable in return argument”。也请找到下面附带的代码,不幸的是我完全被难住了,任何帮助将不胜感激。
package main
// Define an arbitrary game type
type MyGame struct{}
// Create a constructor function for arbitrary game type
func NewMyGame() MyGame {
return MyGame{}
}
// Define an interface defining game types
type Playable interface{}
// In my app it will return a list of constructors matching interface
func Playables() func() Playable {
return NewMyGame
}
func main() {}
UYOU
相关分类