cannot convert t (type interface {}) to type string: need type assertion
来源:互联网 发布:娃娃幼儿园软件 编辑:程序博客网 时间:2024/06/05 09:47
问题:
在使用interface表示任何类型时,如果要将interface转为某一类型,直接强制转换是不行的,例如:
var t interface{} = "abc"s := string(t)
cannot convert t(type interface {}) to type string: need type assertion
这样是不行的,需要进行type assertion类型断言,具体使用方法请参考:
golang 任何类型interface{}
更多信息:
http://blog.csdn.net/lanyang123456/article/details/78070886
阅读全文
0 0
- cannot convert t (type interface {}) to type string: need type assertion
- golang解决cannot convert a (type interface {}) to type *: need type assertion
- Go语言中cannot convert adminname (type interface {}) to type *: need type assertion的解决办法
- Convert string type to int
- Type mismatch: cannot convert from Object to String
- Type mismatch: cannot convert from Enumeration<String> to Enumeration<Object>
- Type mismatch: cannot convert from Object to String
- cannot convert value of type 'String!' to expected argument type 'inout String'
- 配置Spring Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource]
- How to convert string to Guid type.
- Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching e
- Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'xxx'
- Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'xxx'
- String cannot be resolved to a type
- String cannot be resolved to a type
- "String cannot be resolved to a type"
- String cannot be resolved to a type
- String cannot be resolved to a type
- jq代码学习8--事件绑定 fl ch4 p98
- 3D Organon Anatomy(人体3D解剖软件)免安装绿色版V3.0.0下载 | 3D Organon Anatomy 破解版
- JSP学习笔记—JSP概述和背后原理
- 【LibUIDK界面库系列文章】对话框坐标单位
- Qt中配置OpenCV库的另类方法
- cannot convert t (type interface {}) to type string: need type assertion
- Java编程思想---第四章笔记
- 用jQuery实现回到顶部
- 启动hadoop 2.6遇到的datanode启动不了
- LeetCode-87-Scramble String DFS+剪枝
- 剑指Offer------反转链表
- 深入浅出MySQL笔记(二)
- 两种开源聊天机器人的性能测试(一)——ChatterBot
- jq代码学习9--合成事件 fl ch4 105