title: multidimensional array in golang
body: <p>Coming from a language that uses array (PHP) and only 3 days of experience in golang, how can I translate a multi-dimensional array assignment using map (or slice, or combination)</p>
  
  <p>I have this code in PHP:
  $set is a collection of document vectors (string => frequency).</p>
  
  <p>I normally can create a posting statistics like this:</p>
  
  <pre><code>$postinglist = array();  
  
  foreach ($set as $id=&gt;$doc) {
        foreach ($doc as $term =&gt; $value) {
  
        if(!isset($postinglist[$term][$id])) {
            $postinglist[$term][$id] = $value;
        }
  }
  </code></pre>
  
  <p>So it would look something like:</p>
  
  <pre><code>array ( 
     'the' =&gt; array ( 
        1 =&gt; 5, 
        2 =&gt; 10 
        ), 
     'and' =&gt; array ( 
        1 =&gt; 6, 
        3 =&gt; 7
        )
      )
  </code></pre>
  
  <p>After building my corpus (just array of all terms in all documents),
  I would then build the posting list for each terms:</p>
  
  <pre><code>$terms = $this-&gt;getAllTerms();
  
  foreach($terms as $term) {
      $entry = new EntryStatistics();
  
      foreach($postinglist[$term] as $id =&gt; $value) {
         $post = new PostingStatistics;
         $post-&gt;setTf($value);
         $entry-&gt;setPostingList($id, $post);
      }
  }
  </code></pre>
  
  <p>I'm wondering if there's a neat way of doing such in golang as I've tried this:</p>
  
  <pre><code>postinglist := make(map[string]map[int]float64)
  for id, doc := range indexmanager.GetDocuments() {
    for str, tf := range doc {
        _, ok_pl := postinglist[str][id]
        if !ok_pl {
            postinglist[str] = make(map[int]float64)
            postinglist[str][id] = tf
        }
     }
  }
  </code></pre>
  
  <p>Of course it doesn't work, as it always initializes the map everytime I do:</p>
  
  <pre><code>postinglist[str] = make(map[int]float64)
  </code></pre>