-1
func foo(i interface{}) {
switch v := i.(type) {
case int:
fmt.Println("I'm an integer!")
case string:
fmt.Println("I'm a string!")
default:
fmt.Println("Unknown type!")
}
}
I researched this control structure, but as this language is new I don’t find much in our language, my understanding of English is not the best. I took from the book "black hat go" and this code is not working, could anyone tell me why? and how to make it work?
compiler logs(1.13):
# command-line-arguments
./hw.go:6:9: v declared and not used