报错:
non-interface type int32 on left
要点:
传进来的参数不是interface类型那么做类型断言都是回报 non-interface的错误
需要借助interface{}()进行转换
案例:
type IntStr struct {
int32
string
}
func test(){
var a int32
b:=interface{}(a).(IntStr)
klog.Info(b)
}
报错:
non-interface type int32 on left
要点:
传进来的参数不是interface类型那么做类型断言都是回报 non-interface的错误
需要借助interface{}()进行转换
案例:
type IntStr struct {
int32
string
}
func test(){
var a int32
b:=interface{}(a).(IntStr)
klog.Info(b)
}