一直弄不懂 .(type) 是啥,在 liteide 中輸出 (1+1).(type),提示:
use of .(type) outside type switch
於是搜索到這個文章:
作者:翔雲翔雲
來源:CSDN
原文:https://blog.csdn.net/lanyang123456/article/details/78070886
版權聲明:本文爲博主原創文章,轉載請附上博文鏈接!
package main
import (
"fmt"
)
func main() {
CheckType("tow", 88, "three")
}
func CheckType(args ...interface{}) {
for _,v := range args {
switch v.(type) {
case int:
fmt.Println("type:int, value:", v)
case string:
fmt.Println("type:string, value:", v)
default:
fmt.Println("type:unkown,value:",v)
}
}
}