tune update db

This commit is contained in:
thuanle
2024-08-05 15:06:39 +07:00
parent 71ceabdf00
commit f33d064d6e
8 changed files with 128 additions and 9 deletions

34
pkg/osx/file.go Normal file
View File

@@ -0,0 +1,34 @@
package osx
import (
"io"
"os"
)
// Copy copies a file from source to destination
func Copy(from, to string) error {
// Open the source file for reading
srcFile, err := os.Open(from)
if err != nil {
return err
}
defer srcFile.Close()
// Create the destination file for writing
dstFile, err := os.Create(to)
if err != nil {
return err
}
defer dstFile.Close()
// Use a buffer to copy the file in chunks
buf := make([]byte, 1024*1024) // 1 MB buffer
// Copy the data from srcFile to dstFile
_, err = io.CopyBuffer(dstFile, srcFile, buf)
if err != nil {
return err
}
return nil
}