package sql_client import ( "code.30cm.net/digimon/app-cloudep-wallet-service/internal/config" "fmt" "gorm.io/gorm" ) func NewMySQLClient(conf config.Config) (*gorm.DB, error) { dbConf := &Config{ User: conf.MySQL.UserName, Password: conf.MySQL.Password, Host: conf.MySQL.Host, Port: conf.MySQL.Port, Database: conf.MySQL.Database, MaxIdleConns: conf.MySQL.MaxIdleConns, MaxOpenConns: conf.MySQL.MaxOpenConns, ConnMaxLifetime: conf.MySQL.ConnMaxLifetime, InterpolateParams: true, } dbInit := New(dbConf, WithLogLevel(conf.MySQL.LogLevel)) orm, err := dbInit.Conn() if err != nil { return nil, fmt.Errorf("failed to initiate db connection pool: %w", err) } return orm, nil }