golang解决cannot convert a (type interface {}) to type *: need type assertion

cannot convert a (type interface {}) to type string: need type assertion

cannot convert a (type interface {}) to type *: need type assertion


解决方案:

var a interface{} = int(10)
var b MyInt = a.(MyInt)


参考:

http://stackoverflow.com/questions/19577423/how-to-cast-to-a-type-alias-in-go/19579058


版权声明:本文为u010499721原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。