This repository has been archived on 2026-01-01. You can view files and clone it, but cannot push or open issues or pull requests.
2016-06-28 14:59:33 +01:00

31 lines
397 B
Go

package files
import (
"io"
"os"
)
// CopyFile is used to copy a file
func CopyFile(old, new string) error {
// Open the file and create a new one
r, err := os.Open(old)
if err != nil {
return err
}
defer r.Close()
w, err := os.Create(new)
if err != nil {
return err
}
defer w.Close()
// Copy the content
_, err = io.Copy(w, r)
if err != nil {
return err
}
return nil
}