package main import "fmt" type cat struct { name string } func typeExample(i []interface{}) { for _, x := range i { switch v := x.(type) { case int: fmt.Printf("%v is an int\n", v) case string: fmt.Printf("%v is a string\n", v) case bool: fmt.Printf("%v is a boolean\n", v) default: fmt.Printf("Unknown type %T\n", v) } } } func main() { c := cat{"oreo"} i := []interface{}{42, "The book club", true, c} typeExample(i) }