mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
review fixes
This commit is contained in:
parent
69fd3ac324
commit
3db71415c9
4 changed files with 38 additions and 33 deletions
31
irc/utils/os.go
Normal file
31
irc/utils/os.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue