22 lines
299 B
Go
22 lines
299 B
Go
package copyfile2
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
func CopyFile(dstName, srcName string) (written int64, err error) {
|
|
src, err := os.Open(srcName)
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer src.Close()
|
|
|
|
dst, err := os.Create(dstName)
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer dst.Close()
|
|
|
|
return io.Copy(dst, src)
|
|
}
|