1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-22 21:29:02 +08:00
nali/pkg/common/savefile.go
zu1k d1b584c3e7 refactor: better download and error handle
Signed-off-by: zu1k <i@lgf.im>
2022-03-02 12:34:11 +08:00

22 lines
336 B
Go

package common
import (
"io/ioutil"
"log"
"os"
)
func SaveFile(path string, data []byte) (err error) {
// Remove file if exist
_, err = os.Stat(path)
if err == nil {
err = os.Remove(path)
if err != nil {
log.Fatalln("旧文件删除失败", err.Error())
}
}
// save file
return ioutil.WriteFile(path, data, 0644)
}