-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
61 lines (48 loc) · 1.05 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"XArr-Rss/server"
"XArr-Rss/util/logsys"
"embed"
"os"
)
var Version string
func main() {
logsys.Info("软件定制请联系QQ: 319555754 QQ群:996973766 ", "系统")
// 初始化配置文件
resourceInit()
// 初始化配置
server.Run("./conf", Version, &publicDir, menuJson)
}
//go:embed web/data/menu.json
var menuJson []byte
//go:embed web
var publicDir embed.FS
func resourceInit() bool {
createDir("./conf")
createDir("./conf/cache")
createDir("./conf/backup")
createDir("./conf/trans")
createDir("./conf/torrents")
createDir("./conf/data")
createDir("./images")
return true
}
func createDir(dirname string) {
// 判断目录是否存在
dirInfo, err := os.Stat(dirname)
if os.IsNotExist(err) {
// 创建目录
err := os.Mkdir(dirname, 0777)
if err != nil {
logsys.Panicln("创建目录失败,请检查权限", "系统")
}
return
} else if err != nil {
panic(err)
}
if dirInfo.IsDir() == false {
if err != nil {
logsys.Panicln(dirname+" 已有文件存在,请检查", "系统")
}
}
}