package main
import (
. "fmt"
)
func whattype(variable interface{}){ //interface can accept anytype the variable
switch variable.(type) { //create a switch for choose it
case string: // this is one,you can make it for more
Println("this is string type.")
case int:
Println("this is int type.")
case bool:
Println("this is bool type.")
}
}
func main() {
var x string
whattype(x)
}
代码贴上 自己研究
import (
. "fmt"
)
func whattype(variable interface{}){ //interface can accept anytype the variable
switch variable.(type) { //create a switch for choose it
case string: // this is one,you can make it for more
Println("this is string type.")
case int:
Println("this is int type.")
case bool:
Println("this is bool type.")
}
}
func main() {
var x string
whattype(x)
}
