dynamic type checking in golang
func dynamicTypeChecking(value interface{}) {
switch t := value.(type) {
case string:
fmt.Printf("string value is: %q\n", t)
case int:
fmt.Printf("int value is: %d\n", t)
case float64:
fmt.Printf("float value is: %f\n", t)
default:
fmt.Printf("default value is: %q\n", t)
}
}
func main() {
dynamicTypeChecking("test")
dynamicTypeChecking(123)
dynamicTypeChecking(123.44545)
}