title: Go: Passing pointers of an array to gob without copying?
body: <p>I have a very, very large array (not slice) of maps that I am then trying to encode. I really need to avoid making a copy of the array but I can't figure out how to do this.</p>
  
  <p>So I far I have this:</p>
  
  <pre><code>func doSomething() {
   var mygiantvar [5]map[string]Searcher
   mygiantvar = Load()
   Save(`file.gob.gz`, &amp;mygiantvar)
  }
  
  func Save(filename string, variable *[5]map[string]Searcher) error {
      // Open file for writing
      fi, err := os.Create(filename)
      if err !=nil {
          return err
      }
      defer fi.Close()
      // Attach gzip writer
      fz := gzip.NewWriter(fi)
      defer fz.Close()
      // Push from the gob encoder
      encoder := gob.NewEncoder(fz)
      err = encoder.Encode(*variable)
      if err !=nil {
          return err
      }
      return nil
  }
  </code></pre>
  
  <p>From my understanding that will pass a pointer of mygiantvar to Save, which saves the first copy. But then the entire array will surely be copied into <code>encoder.Encode</code> which will then copy it around many more functions, right?</p>
  
  <p>This <code>mygiantvar</code> variable will be something like 10GB in size. So it must avoid being copied ever.</p>
  
  <p>But then again perhaps only the actual array [5] part is copied but the maps inside of this are pointers inside an array, so the array of pointers to maps would be copied instead of the maps themselves? I have no idea about this - it's all very confusing.</p>
  
  <p>Any ideas?</p>