12345678910111213141516 |
- package main
- import (
- "gorm.io/driver/mysql"
- "gorm.io/gorm"
- "log"
- )
- func InitializeGorm(config MySQLConfig) (*gorm.DB, error) {
- db, err := gorm.Open(mysql.Open(config.DSN()), &gorm.Config{})
- if err != nil {
- log.Printf("failed to connect database: %v", err)
- return nil, err
- }
- return db, nil
- }
|