I have a simple function which takes a variable gets its type and processes it in to a switch but i get an error :
i is not a type
My code looks like this:
var whatAmI = func(i, interface{}) { // error is here
switch t := i.(type) {
case bool:
fmt.Println("I'm a bool!")
case int:
fmt.Println("I'm an int!")
default:
fmt.Println("Don't know type %T
", t)
}
}
whatAmI(true)
whatAmI(1)
whatAmI("hey")
Am i misunderstanding something here?