code: func (w *CompoundFileWriter) Close() (err error) {
  	if w.closed {
  		fmt.Println("CompoundFileWriter is already closed.")
  		return nil
  	}
  
  	// TODO this code should clean up after itself (remove partial .cfs/.cfe)
  	if err = func() (err error) {
  		var success = false
  		defer func() {
  			if success {
  				util.Close(w.dataOut)
  			} else {
  				util.CloseWhileSuppressingError(w.dataOut)
  			}
  		}()
  
  		assert2(w.pendingEntries.Len() == 0 && !w.outputTaken.Get(),
  			"CFS has pending open files")
  		w.closed = true
  		// open the compound stream; we can safely use IO_CONTEXT_DEFAULT
  		// here because this will only open the output if no file was
  		// added to the CFS
  		_, err = w.output(IO_CONTEXT_DEFAULT)
  		if err != nil {
  			return
  		}
  		assert(w.dataOut != nil)
  		err = codec.WriteFooter(w.dataOut)
  		if err != nil {
  			return
  		}
  		success = true
  		return nil
  	}(); err != nil {
  		return
  	}
  
  	var entryTableOut IndexOutput
  	var success = false
  	defer func() {
  		if success {
  			util.Close(entryTableOut)
  		} else {
  			util.CloseWhileSuppressingError(entryTableOut)
  		}
  	}()
  	entryTableOut, err = w.directory.CreateOutput(w.entryTableName, IO_CONTEXT_DEFAULT)
  	if err != nil {
  		return
  	}
  	err = w.writeEntryTable(w.entries, entryTableOut)
  	if err != nil {
  		return
  	}
  	success = true
  	return
  }
docs: /* Closes all resouces and writes the entry table */