golang: How can I populate a multi-struct map in a loop? <p>I have log files of customer interactions with an API. I want to parse those logs and feed the results into a map of structs so that I can organize the data into helpful information. For example, I would like to respond to the following query: "show me the total number of requests per user per day".</p> <p>I have created what seems like an adequate structure to hold the data. However, when I try to run the program I get the error: <code>invalid operation: dates[fields[1]] (type *Dates does not support indexing) [process exited with non-zero status]</code>.</p> <p><a href="http://play.golang.org/p/8u3jX26ktt" rel="nofollow">http://play.golang.org/p/8u3jX26ktt</a></p> <pre><code>package main import ( "fmt" "strings" ) type Stats struct { totalNumberOfRequests int } type Customer struct { listOfCustomers map[string]Stats // map[customerid]Stats } type Dates struct { listOfDates map[string]Customer // map[date]Customer } var requestLog = []string{ "2011-10-05, 1234, apiquery", "2011-10-06, 1234, apiquery", "2011-10-06, 5678, apiquery", "2011-10-09, 1234, apiquery", "2011-10-12, 1234, apiquery", "2011-10-13, 1234, apiquery", } func main() { dates := new(Dates) for _, entry := range requestLog { fmt.Println("entry:", entry) fields := strings.Split(entry, "'") dates.listOfDates[fields[0]].listOfCustomers[fields[1]].totalNumberOfRequests++ } } </code></pre> <p>Is there a better structure to use? Or is there a way to make this structure work for this particular purpose?</p>