A Go library for recursively copying directories with extensive customization options.
Copy is a Go library that provides recursive directory copying functionality. It solves the problem of reliably copying entire directory trees in Go applications, handling symlinks, permissions, and concurrency. The library offers extensive customization through options for error handling, file skipping, and metadata preservation.
Go developers who need to copy directories in their applications, such as those building backup tools, deployment scripts, or file synchronization utilities.
Developers choose Copy because it's a dedicated, well-tested library that handles edge cases better than manual implementations. Its rich options and support for concurrent copying make it both flexible and performant for complex file operations.
Go copy directory recursively
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Efficiently copies entire directory trees while preserving structure, as shown in the basic Copy function that handles all subdirectories automatically.
Offers a comprehensive Options struct with callbacks for symlinks, errors, and file skipping, allowing developers to tailor behavior to complex edge cases.
Supports configurable worker counts via NumOfWorkers for faster copying of large directories, leveraging Go's goroutines for scalability.
Works with any fs.FS implementation, including embedded filesystems like embed.FS, enabling versatile use beyond the OS filesystem.
Provides OnError callbacks for custom error handling and recovery, as detailed in the Options, making it robust for production environments.
On Linux, the PreserveTimes option only guarantees accuracy up to 1 millisecond, which may not meet the needs of applications requiring precise file metadata.
The Options struct has numerous fields, such as WrapReader and PreferConcurrent, which can be overwhelming and increase the risk of misconfiguration for simple tasks.
Lacks native hooks for monitoring copy progress, requiring additional code for applications that need to provide user feedback or UI updates.
Adding this library as a dependency expands the final binary size, which could be a concern for resource-constrained deployments or minimalist Go applications.