Skip to content

Add file.Copy function to copy files with permissions #3

@piraz

Description

@piraz

Implement a new function Copy in the file package to copy a file from a source path to a destination path, preserving file content and permissions.

Acceptance Criteria

  • Add Copy(src, dst string) error to the file package.
  • The function should:
    • Copy the file's content from src to dst.
    • Overwrite dst if it exists, or create it if it doesn't.
    • Preserve the file mode (permissions) from the source file.
    • Return an error if the operation fails.
  • Add GoDoc documentation for the function.
  • Include basic unit tests (using testify) to verify correct behavior.

Example usage:

err := file.Copy("foo.txt", "bar.txt")
if err != nil {
    log.Fatal(err)
}

This utility will make it easier to copy files in Go projects using fsok.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions