This commit is contained in:
admju
2024-09-02 07:09:46 +00:00
parent 00d92b73f8
commit 4ae5926b01
40 changed files with 1711 additions and 0 deletions

35
src/utils/copyFile.go Normal file
View File

@@ -0,0 +1,35 @@
package utils
import (
"os"
"io"
"path/filepath"
)
func CopyFile(src string, dst string) (error) {
if _, err := os.Stat(src); err != nil {
return err
}
fin, errOpen := os.Open(src)
if errOpen != nil {
return errOpen
}
defer fin.Close()
folderPath := filepath.Dir(dst)
os.MkdirAll(folderPath, os.ModePerm)
fout, errCreate := os.Create(dst)
if errCreate != nil {
return errCreate
}
defer fout.Close()
_, errCopy := io.Copy(fout, fin)
if errCopy != nil {
return errCopy
}
return nil
}