shad-go/lectures/02-interfaces/copyfile/copy.go
2021-02-25 16:08:25 +03:00

23 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
}