code: func (d *DirectoryImpl) Copy(to Directory, src, dest string, ctx IOContext) (err error) {
  	var os IndexOutput
  	var is IndexInput
  	var success = false
  	defer func() {
  		if success {
  			err = util.Close(os, is)
  		} else {
  			util.CloseWhileSuppressingError(os, is)
  		}
  		defer func() {
  			recover() // ignore panic
  		}()
  		to.DeleteFile(dest) // ignore error
  	}()
  
  	os, err = to.CreateOutput(dest, ctx)
  	if err != nil {
  		return err
  	}
  	is, err = d.spi.OpenInput(src, ctx)
  	if err != nil {
  		return err
  	}
  	err = os.CopyBytes(is, is.Length())
  	if err != nil {
  		return err
  	}
  	success = true
  	return nil
  }
docs: /*
  Copies the file src to 'to' under the new file name dest.
  
  If you want to copy the entire source directory to the destination
  one, you can do so like this:
  
  		var to Directory // the directory to copy to
  		for _, file := range dir.ListAll() {
  			dir.Copy(to, file, newFile, IO_CONTEXT_DEFAULT)
  			// newFile can be either file, or a new name
  		}
  
  NOTE: this method does not check whether dest exists and will
  overwrite it if it does.
  */