3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 11:59:40 +01:00
ergo/irc/utils/os.go
Shivaram Lingamneni 3db71415c9 review fixes
2018-04-20 03:59:01 -04:00

32 lines
481 B
Go

// Copyright (c) 2018 Shivaram Lingamneni
package utils
import (
"io"
"os"
)
// implementation of `cp` (go should really provide this...)
func CopyFile(src string, dst string) (err error) {
in, err := os.Open(src)
if err != nil {
return
}
defer in.Close()
out, err := os.Create(dst)
if err != nil {
return
}
defer func() {
closeError := out.Close()
if err == nil {
err = closeError
}
}()
if _, err = io.Copy(out, in); err != nil {
return
}
return
}