add an option to deep-copy symlinks
yasushi-saito opened this issue · comments
Can we have an option to copy symlinks? I'm imagining something like:
Opts struct {
// Called if a symlink is found. If this function returns false,
// Copy copies the symlink itself. Else, Copy() follows the link.
// If FollowSymlink=nil, Copy never follows symlinks.
FollowSymlink func(path string) bool
}
func Copy(src, dest string, opt... Opts) error;
I can create a pull request if it looks good.
Can you please list up expected usecases of this option first?
From my perspective, there are 3 usecases when it comes to symlink:
- Hard copy
- Soft copy (create a link to the same resource)
- Ignore
What do you think?
Yes, the only feature I need now is deep-copies (i.e., follow all symlinks). So we can just have
type Opt struct { FollowSymlink bool }
I can't think a use case to ignore symlinks.
OK, then
- Hard copy ← is this what you want?
- Soft copy (create symlink)
(follow) what you want - Others (Skip?)
Is it right?
hmm, confusing... I'm still not sure what you want since your test cases are not descriptive enough and even failing.