You initialize the cities as a slice of nodes with one element (empty node).
You can initialize it to a fixed size using cities := make([]node,47) , or you can initialize it to an empty slice and append to it:
cities := []node{} for i := 0; i<47 ;i++ { n := node{name: strconv.Itoa(i), children: map[string]int{}} cities = append(cities,n) }
I would definitely recommend reading this article if you are unsteady about how slicers work.
source share