【发布时间】:2014-02-23 20:24:31
【问题描述】:
我有一个我认为类型为“[]interface {}”的变量
- 我如何检测它
- 转换为数组?
代码如下:
var s string
switch value1 := value1.(type) {
case int:
s = strconv.Itoa(value1)
case float64:
s = strconv.FormatFloat(value1, 'f', 0, 64)
//case array:
//fmt.Printf("array")
default :
fmt.Printf("\nvalue=v+%",value1)
}
输出是:
value=v+%!(NOVERB)%!(EXTRA []interface {}=
【问题讨论】:
-
能否正确格式化代码?