From f9b57db47556ecf6801bbb8a92cd7e4849eae5c0 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Mon, 16 Dec 2024 18:15:15 +0800 Subject: [PATCH] change init --- .gitea/workflows/go.yaml | 4 ++-- main.go | 16 +--------------- models/init.go | 2 +- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 5e7c8eb..8c4887a 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -18,9 +18,9 @@ jobs: - name: Set up Docker Buildx uses: https://gitea.com/docker/setup-buildx-action@v3 - - name: Build Docker image + - name: Build Docker image RUN_ID= $GITEA_RUN_ID RUN_NUMBER= $GITEA_RUN_NUMBER run: | - docker build -t go_blog:latest -f ./Dockerfile . + docker build -t go_blog:$GITEA_RUN_ID -f ./Dockerfile . - name: Run Docker container run: | diff --git a/main.go b/main.go index 7dc1176..39e0ff9 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "flag" "fmt" "go_blog/conf" "go_blog/controllers" @@ -22,24 +21,11 @@ type User struct { PasswordHash []byte } -var host string -var port string -var isDebugMode bool -var isErrMsg bool -var isOrmDebug bool - const templatePath = "./templates/*" func init() { - flag.StringVar(&host, "h", "127.0.0.1", "主机") - flag.StringVar(&port, "p", "", "监听端口") - flag.BoolVar(&isDebugMode, "debug", true, "是否开启debug") - flag.BoolVar(&isErrMsg, "err", true, "是否返回错误信息") - flag.BoolVar(&isOrmDebug, "orm", true, "是否开启gorm的debug信息") - flag.Parse() - conf.SetUp() - models.SetUp(isOrmDebug) + models.SetUp() } func main() { diff --git a/models/init.go b/models/init.go index 87e3390..99849bb 100644 --- a/models/init.go +++ b/models/init.go @@ -19,7 +19,7 @@ import ( var DB *gorm.DB -func SetUp(isOrmDebug bool) { +func SetUp() { conUri := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=%s&parseTime=True&loc=Local", conf.DataBase.User, conf.DataBase.Password,