change init

This commit is contained in:
zhangchao
2024-12-16 18:15:15 +08:00
parent 2947fa7d3e
commit f9b57db475
3 changed files with 4 additions and 18 deletions

View File

@@ -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: |

16
main.go
View File

@@ -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() {

View File

@@ -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,