mirror of
https://github.com/zu1k/nali.git
synced 2025-01-23 05:39:03 +08:00
22 lines
336 B
Go
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)
|
||
|
}
|