💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
~~~ package sqlx import ( "fmt" "github.com/jmoiron/sqlx" "project/library/dao/common" "project/library/dao/config" "time" ) type SqlxMgr struct { Conn *sqlx.DB } func InitSqlx(cfg *config.MysqlCfg) *SqlxMgr { conn, err := sqlx.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.SetMaxIdleConns(1024) conn.SetMaxOpenConns(1024) conn.SetConnMaxLifetime(9 * time.Second) } return &SqlxMgr{Conn: conn} } ~~~