title: Go : assignment to entry in nil map
body: <p>When trying to set value to the <code>map</code>(<code>countedData</code>) in the below code, I am getting an error that says, <code>assignment to entry in nil map</code>. </p>
  
  <pre><code>func receiveWork(out &lt;-chan Work) map[string][]ChartElement {
  
      var countedData map[string][]ChartElement
  
      for el := range out {
          countedData[el.Name] = el.Data
      }
      fmt.Println("This is never executed !!!")
  
      return countedData
  }
  </code></pre>
  
  <p><code>Println</code> does not execute (as the error occurs on a lien before that). </p>
  
  <p>There are some goroutines , that are sending data to channel, and <code>receiveWork</code> method should be making a map like this: </p>
  
  <pre><code>map =&gt;
      "typeOne" =&gt; 
         [
           ChartElement,
           ChartElement,
           ChartElement,
         ],
      "typeTwo" =&gt; 
         [
           ChartElement,
           ChartElement,
           ChartElement,
         ]
  </code></pre>
  
  <p>Please help me fix the error.</p>