https://github.com/werf/copy-recurse
Effective recursive file copying
https://github.com/werf/copy-recurse
Last synced: about 1 year ago
JSON representation
Effective recursive file copying
- Host: GitHub
- URL: https://github.com/werf/copy-recurse
- Owner: werf
- License: apache-2.0
- Created: 2022-04-18T10:11:16.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-15T16:30:00.000Z (over 2 years ago)
- Last Synced: 2024-06-21T05:01:43.146Z (almost 2 years ago)
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Effective recursive file copying
## Usage
Basic:
```go
copyRec, err := copyrec.New(src, dest, copyrec.Options{})
if err != nil {
return err
}
copyRec.Run(ctx)
```
Advanced:
```go
uid, gid := uint32(1000), uint32(1000)
copyRec, err := copyrec.New(src, dest, copyrec.Options{
UID: &uid,
GID: &gid,
MatchDir: func(path string) (copyrec.DirAction, error) {
switch filepath.Base(path) {
case "match-this-dir-fully":
return copyrec.DirMatch, nil
case "skip-this-dir":
return copyrec.DirSkip, nil
default:
return copyrec.DirFallThrough, nil
}
},
MatchFile: func(path string) (bool, error) {
return filepath.Base(path) == "match-only-this-filename", nil
},
})
if err != nil {
return err
}
copyRec.Run(ctx)
```