Skip to content

Commit

Permalink
fix the main logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Done authored and Bruce Done committed Jul 15, 2020
1 parent 8633b8a commit b0e5d0f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
clock-linux-64
clock-mac-64
clock-win-64.exe.exe
build.sh
clock-win-64.exe
build.sh
clock.db
8 changes: 4 additions & 4 deletions config/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ storage:
#conn: "host=127.0.0.1 port=5432 user=clock dbname=clock password=clock sslmode=disable"

# sqlite
#backend: "sqlite3"
#conn: "clock.db"
backend: "sqlite3"
conn: "clock.db"

# mysql
backend: "mysql"
conn: "clock:aabbccdd.com@tcp(127.0.0.1:3307)/clock?charset=utf8&parseTime=True&loc=Local"
#backend: "mysql"
#conn: "clock:aabbccdd.com@tcp(127.0.0.1:3307)/clock?charset=utf8&parseTime=True&loc=Local"

login:
user: "admin"
Expand Down
16 changes: 4 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,22 @@ Options:
flag.PrintDefaults()
}

func setFlag() {
flag.StringVar(&filePath, "c", "./config.yaml", "根目录所在")
func main() {
flag.StringVar(&filePath, "c", "./config.yaml", "配置文件所在")
flag.BoolVar(&help, "h", false, "帮助")
flag.Usage = usage
flag.Parse()

if help {
flag.PrintDefaults()
return
}
}


func prepare() {
setFlag()
// 设置配置文件和静态变量
config.SetConfig(filePath)
param.SetStatic()
storage.SetDb()
}

func main() {
prepare()

defer storage.Db.Close()

address := config.Config.GetString("server.host")
if address == "" {
logrus.Fatal("can not find any server host config")
Expand Down

0 comments on commit b0e5d0f

Please sign in to comment.