标签:interface highlight 打印 bool 技术 printf 利用 com previous
package main
import(
"fmt"
_"sort"
_"math/rand"
)
type Wisdom struct{
name string
}
func TypeJuDge (Items... interface{}) {
for index, value := range Items {
switch value.(type){
case bool:
fmt.Printf("第%v个参数是布尔类型,它的值是%v \n",index+1,value)
case string:
fmt.Printf("第%v个参数是字符串类型,它的值是%v \n",index+1,value)
case int,int32,int64:
fmt.Printf("第%v个参数是整数类型,它的值是%v \n",index+1,value)
case float32,float64:
fmt.Printf("第%v个参数是浮点类型,它的值是%v \n",index+1,value)
// case bool:
// fmt.Printf("第%v个参数是bool类型,它的值是%v \n",index+1,value)
case Wisdom:
fmt.Printf("第%v个参数是自定义Wisdom类型,它的值是%v \n",index+1,value)
case *Wisdom:
fmt.Printf("第%v个参数是自定义Wisdom指针类型,它的值是%v \n",index+1,value)
}
}
}
func main(){
wisdom := Wisdom{ "智慧"}
wisdom2 := &Wisdom{ "人名"}
var n1 float64 = 68.9
var n2 bool
var n3 int = 100
var name string = "GOLANG"
TypeJuDge(wisdom,wisdom2,n1,n2,n3,name)
}

标签:interface highlight 打印 bool 技术 printf 利用 com previous
原文地址:https://www.cnblogs.com/swei/p/10838464.html