新增文件管理

This commit is contained in:
zyj
2025-07-14 19:01:02 +08:00
parent 2d000db739
commit daedfbde7d

20
file/index.go Normal file
View File

@@ -0,0 +1,20 @@
package file
import (
"os"
)
// 判断日志文件是否存在
func LogFileExists(path string, name string) *os.File {
var filePath string = path
if filePath != "" {
logFile, _ := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
logFile.Close()
return logFile
} else {
filePath = "/log/" + name + ".log"
logFile, _ := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
logFile.Close()
return logFile
}
}