💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
~~~ package gorm import ( "fmt" "github.com/jinzhu/gorm" "project/library/dao/common" "project/library/dao/config" "time" ) type GormMgr struct { Conn *gorm.DB } func InitGorm(cfg *config.MysqlCfg) *GormMgr { conn, err := gorm.Open("mysql", fmt.Sprintf("%s:%s@(%s)/%s?charset=utf8&parseTime=True&loc=Local", cfg.User, cfg.Password, cfg.Addrs, cfg.DBName)) if err != nil { common.SimplePanic("InitGorm失败", err.Error()) } else { conn.DB().SetMaxIdleConns(1024) conn.DB().SetMaxOpenConns(1024) conn.DB().SetConnMaxLifetime(9 * time.Second) } return &GormMgr{Conn: conn} } ~~~