Zeus/helper/gorm_helper.go

14 lines
314 B
Go

package bgm
import (
"fmt"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
func GormMap(dsnPre string) (map[string]*gorm.DB, error) {
dsn := fmt.Sprintf("%v/test?charset=utf8mb4&parseTime=True&loc=Local", dsnPre)
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
return map[string]*gorm.DB{"local": db}, err
}