【发布时间】:2014-12-02 08:13:18
【问题描述】:
我正在尝试将字符串数组传递给方法。虽然它通过了断言,但我收到了这个错误
cannot use temp (type interface {}) as type []string in argument to equalStringArray: need type assertion
代码:
if str, ok := temp.([]string); ok {
if !equalStringArray(temp, someotherStringArray) {
// do something
} else {
// do something else
}
}
我也试过用reflect.TypeOf(temp)检查类型,这也在打印[]string
【问题讨论】:
标签: go