标签:div unknown str cas UNC bool bsp fun ring
任意类型
interface{}
遍历并判断类型
func MyPrintf(args ...interface{}) { for _, arg := range args { switch arg.(type) { case int: fmt.Println(arg, "is an int value.") case string: fmt.Println(arg, "is a string value.") case float64: fmt.Println(arg, "is an float64 value.") case bool: fmt.Println(arg, "is an bool value.") default: fmt.Println(arg, "is an unknown type.") } } }
标签:div unknown str cas UNC bool bsp fun ring
原文地址:https://www.cnblogs.com/webglcn/p/9407242.html