Upgrade to 1.21 as 1.20 is now unmaintained. Most changes are related to the new `slices` package from standard library, which can replace some existing custom functions.
24 lines
298 B
Go
24 lines
298 B
Go
package util
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
func CopyFile(srcPath, dstPath string) error {
|
|
fin, err := os.Open(srcPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer fin.Close()
|
|
|
|
fout, err := os.Create(dstPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer fout.Close()
|
|
|
|
_, err = io.Copy(fout, fin)
|
|
return err
|
|
}
|