review fixes

This commit is contained in:
Shivaram Lingamneni 2018-04-20 03:57:48 -04:00
parent 69fd3ac324
commit 3db71415c9
4 changed files with 38 additions and 33 deletions

31
irc/utils/os.go Normal file
View file

@ -0,0 +1,31 @@
// 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
}