我正在尝试将字符串数组传递给方法。虽然它通过了断言,但我收到了这个错误
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
相关分类