Compare commits
No commits in common. "b1f0eb276988202cea48942887979437ecbedd21" and "3239644cc2dd74826f08ccf99ed008cc584033f4" have entirely different histories.
b1f0eb2769
...
3239644cc2
26
util.go
26
util.go
@ -2,7 +2,6 @@ package goutil
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
"regexp"
|
||||
@ -44,28 +43,3 @@ func Mkdirp(p string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// straight outta stackoverflow
|
||||
// https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang
|
||||
func CopyFile(src, 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() {
|
||||
cerr := out.Close()
|
||||
if err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
if _, err = io.Copy(out, in); err != nil {
|
||||
return
|
||||
}
|
||||
err = out.Sync()
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user