新增文件管理
This commit is contained in:
20
file/index.go
Normal file
20
file/index.go
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user