-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (39 loc) · 827 Bytes
/
main.go
File metadata and controls
48 lines (39 loc) · 827 Bytes
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
package main
import (
"flag"
"mkBlog/config"
"mkBlog/models"
"mkBlog/pkg/bloom"
"mkBlog/pkg/cache"
"mkBlog/pkg/log"
"mkBlog/pkg/middleware"
"mkBlog/pkg/router"
"mkBlog/service"
"os"
)
func Init(debugflag *bool) {
if err := os.MkdirAll(models.Default_Data_Path, 0755); err != nil {
return
}
if debugflag != nil {
log.Init(*debugflag)
} else {
log.Init(false)
}
config.Init()
bloom.Init()
cache.Init(models.Default_Static_File_Path)
middleware.Init()
}
func main() {
debug := flag.Bool("debug", false, "启用调试模式")
// 解析命令行参数
flag.Parse()
Init(debug)
if err := router.InitRouter(); err != nil {
panic("failed to create router: " + err.Error())
}
if s, err := service.NewBlogService(); err == nil {
s.Start()
}
}