code: func (s Storage) recordModule(rec moduleRecord) error {
  	manifest, err := s.loadManifest()
  	if err != nil {
  		// if there was a problem with the file, we will attempt to write a new
  		// one. Any non-data related error should surface there.
  		log.Printf("[WARN] error reading module manifest: %s", err)
  	}
  
  	// do nothing if we already have the exact module
  	for i, stored := range manifest.Modules {
  		if rec == stored {
  			return nil
  		}
  
  		// they are not equal, but if the storage path is the same we need to
  		// remove this rec to be replaced.
  		if rec.Dir == stored.Dir {
  			manifest.Modules[i] = manifest.Modules[len(manifest.Modules)-1]
  			manifest.Modules = manifest.Modules[:len(manifest.Modules)-1]
  			break
  		}
  	}
  
  	manifest.Modules = append(manifest.Modules, rec)
  
  	js, err := json.Marshal(manifest)
  	if err != nil {
  		panic(err)
  	}
  
  	manifestPath := filepath.Join(s.StorageDir, manifestName)
  	return ioutil.WriteFile(manifestPath, js, 0644)
  }
docs: // Store the location of the module, along with the version used and the module
  // root directory. The storage method loads the entire file and rewrites it
  // each time. This is only done a few times during init, so efficiency is
  // not a concern.