The copy_utils.go
file in the utils
package provides functions for copying files and directories, allowing for deep copying of directory structures and selective file copying based on patterns.
CopyDir
recursively copies a directory along with its subdirectories and files from the source to the destination.
err := CopyDir(src, dest)
Parameter | Type | Description |
---|---|---|
src | string |
The source directory path. |
dest | string |
The destination directory path. |
return value | error |
Error object if an error occurs, otherwise nil. |
CopyFile
copies a single file from the source path to the destination path.
err := CopyFile(src, dest)
Parameter | Type | Description |
---|---|---|
src | string |
The source file path. |
dest | string |
The destination file path. |
return value | error |
Error object if an error occurs, otherwise nil. |
CopySelectFilesToDestination
copies selected files from the source directory to the destination directory based on a glob pattern.
err := CopySelectFilesToDestination(c CopySelectFilesToDestinationStruct)
Parameter | Type | Description |
---|---|---|
c | CopySelectFilesToDestinationStruct |
Struct containing source files, glob pattern, and destination directory. |
return value | error |
Error object if an error occurs, otherwise nil. |
Field | Type | Description |
---|---|---|
SourceFiles | []string |
Array of source file paths. |
GlobPattern | string |
Glob pattern to match files. |
DestinationDir | string |
The destination directory path. |
This utility function streamlines the process of copying specific files, enhancing file management operations in Go applications.