报错:
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)
}
package main import ( "fmt" "log" "net" "os" "strconv" ) func main() { //源端口 argument1 := os
目錄結構: calc.go package main import ( "fmt" "os" "simplemath" "strconv" ) var Usage = func() {