refactor(user): 重构用户服务配置和依赖
- 更新 MySQL配置,增加端口变量- 初始化 MySQL 在 gorm_gen工具中 - 更新 go.mod 依赖版本: - mysql驱动从 1.7.0 到 1.8.1 - gorm相关包从多个版本统一到 1.25.7 - 其他依赖也进行了升级 - 更新 go.sum 文件以反映新的依赖版本
This commit is contained in:
@@ -2,6 +2,7 @@ package mysql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/suyiiyii/hertz101/app/user/conf"
|
||||
"os"
|
||||
|
||||
@@ -15,7 +16,11 @@ var (
|
||||
)
|
||||
|
||||
func Init() {
|
||||
dsn := fmt.Sprintf(conf.GetConf().MySQL.DSN, os.Getenv("MYSQL_USER"), os.Getenv("MYSQL_PASSWORD"), os.Getenv("MYSQL_HOST"))
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
dsn := fmt.Sprintf(conf.GetConf().MySQL.DSN, os.Getenv("MYSQL_USER"), os.Getenv("MYSQL_PASSWORD"), os.Getenv("MYSQL_HOST"), os.Getenv("MYSQL_PORT"))
|
||||
DB, err = gorm.Open(mysql.Open(dsn),
|
||||
&gorm.Config{
|
||||
PrepareStmt: true,
|
||||
|
||||
Reference in New Issue
Block a user