change init
This commit is contained in:
@@ -18,9 +18,9 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: https://gitea.com/docker/setup-buildx-action@v3
|
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: |
|
run: |
|
||||||
docker build -t go_blog:latest -f ./Dockerfile .
|
docker build -t go_blog:$GITEA_RUN_ID -f ./Dockerfile .
|
||||||
|
|
||||||
- name: Run Docker container
|
- name: Run Docker container
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
16
main.go
16
main.go
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"go_blog/conf"
|
"go_blog/conf"
|
||||||
"go_blog/controllers"
|
"go_blog/controllers"
|
||||||
@@ -22,24 +21,11 @@ type User struct {
|
|||||||
PasswordHash []byte
|
PasswordHash []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
var host string
|
|
||||||
var port string
|
|
||||||
var isDebugMode bool
|
|
||||||
var isErrMsg bool
|
|
||||||
var isOrmDebug bool
|
|
||||||
|
|
||||||
const templatePath = "./templates/*"
|
const templatePath = "./templates/*"
|
||||||
|
|
||||||
func init() {
|
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()
|
conf.SetUp()
|
||||||
models.SetUp(isOrmDebug)
|
models.SetUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
var DB *gorm.DB
|
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",
|
conUri := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=%s&parseTime=True&loc=Local",
|
||||||
conf.DataBase.User,
|
conf.DataBase.User,
|
||||||
conf.DataBase.Password,
|
conf.DataBase.Password,
|
||||||
|
|||||||
Reference in New Issue
Block a user