gin-hello/main.go
2022-07-15 23:23:40 +08:00

29 lines
671 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"flag"
"github.com/NothAmor/gin-hello/app"
"github.com/NothAmor/gin-hello/app/database"
)
var (
root string
migrate bool
)
func main() {
// 指定程序运行目录,必须参数
flag.StringVar(&root, "appRoot", "", "Usage: --appRoot=/www/gin-hello Define Application main directory")
// 是否migrate数据库非必需但首次运行时必须携带此参数
flag.BoolVar(&migrate, "migrate", false, "Usage: --migrate Migrate the database.")
flag.Parse()
// 如果有migrate参数则migrate数据库
database.DatabaseMigrate(database.InitDatabase(), migrate)
// 启动系统
app.Init(root)
}