otiai10 / copy

Go copy directory recursively

Home Page:https://pkg.go.dev/github.com/otiai10/copy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Symbolic links are not handled correctly

fumoboy007 opened this issue · comments

Symbolic links need to be handled separately from directories and regular files.

Example Failure

  • myDir
  • mySymlink → myDir

Calling Copy("mySymlink", "mySymlink2") fails because the library tries to read the file like a regular file, which fails because the symbolic link is pointing to a directory.

Fix

The fix is to check whether a file is a symbolic link and if so, call a new function that simply copies the link to the destination.