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