func main() {
a := 123
//如果是int ok 就为true 并把值附给val
val, ok := interface{}(a).(int)
selectType(a)
}
func selectType(a... interface{}) {
for _, v := range a {
switch v.(type) {
case int:
fmt.Println("is int type1")
}
}
}
golang 类型判断
发表于 2021-03-02 1.34k 次阅读
COMMENTS | NOTHING