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

前端之家收集整理的这篇文章主要介绍了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

原文链接:https://www.f2er.com/go/190615.html

猜你在找的Go相关文章