使用go语言判断不同数据类型

阅读 127

2022-11-22

代码演示案例

package main

import (
"fmt"
)

func TypeCheck(items... interface{}){
for _,item:=range items {
switch item.(type) {
case bool :
fmt.Println("this is bool");
case string:
fmt.Println("this is string");
case int:
fmt.Println("this is int");
default:
fmt.Println("not know params Type");
}
}
}

func main() {
TypeCheck(true,"sdfdsds",10);
}

 

精彩评论(0)

0 0 举报