17 lines
371 B
Go
17 lines
371 B
Go
package bgm
|
|
|
|
import (
|
|
"bgm/consts"
|
|
"fmt"
|
|
"gorm.io/driver/mysql"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type MysqlMap map[string]*gorm.DB
|
|
|
|
func GormMap(dsnPre string) (MysqlMap, error) {
|
|
dsn := fmt.Sprintf("%v/%v?charset=utf8mb4&parseTime=True&loc=Local", dsnPre, consts.TestDB)
|
|
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
|
return map[string]*gorm.DB{consts.TestDB: db}, err
|
|
}
|