title: Grouping maps/structs by key, and summing the associated values for an array
body: <p>I have an array of structs that i've built by getting a word frequency count for a list of sentences. The output from this is the most popular words <strong>per sentence</strong>. I need it across all sentences</p>
  
  <p>Here are the structs:</p>
  
  <pre><code>type WordCountStruct struct {
      word string
      freq int
  }
  
  type WordCountStructArray []WordCountStruct
  </code></pre>
  
  <p>This is a sample of the WordCountStructArray:</p>
  
  <pre><code>[{the 8} {and 8} {to 7} {and 6} {and 6}]
  </code></pre>
  
  <p>So what this is is an ordered list, for each sentence, of the most common words. <strong>I need to group by the key, and sum the values</strong></p>
  
  <p>In the case of the 5 sample set above, this would result in:</p>
  
  <pre><code>[{the 8} {to 7} {and 20}]
  </code></pre>
  
  <p>I can convert the struct to a []map[string]interface{} if this is easier?</p>