code: func (w *CompoundFileWriter) copyFileEntry(dataOut IndexOutput, fileEntry *FileEntry) (n int64, err error) {
  	var is IndexInput
  	is, err = fileEntry.dir.OpenInput(fileEntry.file, IO_CONTEXT_READONCE)
  	if err != nil {
  		return 0, err
  	}
  	var success = false
  	defer func() {
  		if success {
  			err = util.Close(is)
  			// copy successful - delete file
  			if err == nil {
  				fileEntry.dir.DeleteFile(fileEntry.file) // ignore error
  			}
  		} else {
  			util.CloseWhileSuppressingError(is)
  		}
  	}()
  
  	startPtr := dataOut.FilePointer()
  	length := fileEntry.length
  	err = dataOut.CopyBytes(is, length)
  	if err != nil {
  		return 0, err
  	}
  	// verify that the output length diff is equal to original file
  	endPtr := dataOut.FilePointer()
  	diff := endPtr - startPtr
  	if diff != length {
  		return 0, errors.New(fmt.Sprintf(
  			"Difference in the output file offsets %v does not match the original file length %v",
  			diff, length))
  	}
  	fileEntry.offset = startPtr
  	success = true
  	return length, nil
  }
docs: /* Copy the contents of the file with specified extension into the provided output stream. */