golang 空接口断言数据类型
func AssInterface(p interface{}) { switch p.(type) { case int: fmt.Println("is integer data") case string: fmt.Println("is string data") case bool: fmt.Println("is bool data") default: fmt.Println("unknow type") } } AssInterface("hello 世界") // is string data AssInterface(true) // is bool data AssInterface(123) // is integer data