package main
import "fmt"
func do(i interface{}) {
switch a := i.(type) {
case int:
fmt.Printf("int")
case string:
fmt.Printf("string")
default:
fmt.Printf("I don't know about type")
}
}
func main() {
do(21)
do("hello")
do(true)
}
The above code will not work as var a is declared but not used.
Switch case will not allow me to use _.
But I don’t want that data I just want that type.
can we do this in another way?
Thanks.