Mixed map
examples/mixed-map/mixed_map.go
package main import "fmt" func main() { person := make(map[string]interface{}) person["name"] = "Foo Bar" person["year"] = 1998 person["children"] = []string{"Joe", "Jane", "Jannet"} fmt.Println(person) for key, value := range person { fmt.Printf("%v %T\n", key, value) } // to iterate over interface one needs to use the .(T) modifyer for index, name := range person["children"].([]string) { fmt.Printf(" %v %v\n", index, name) } }
map[children:[Joe Jane Jannet] name:Foo Bar year:1998] name string year int children []string 0 Joe 1 Jane 2 Jannet