Skip to content

Instantly share code, notes, and snippets.

@manakuro
Created January 17, 2020 02:22
Show Gist options
  • Save manakuro/1a4f2c8f90281cf39d4189241e6853a6 to your computer and use it in GitHub Desktop.
Save manakuro/1a4f2c8f90281cf39d4189241e6853a6 to your computer and use it in GitHub Desktop.
package datastore
import (
"github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
)
func NewDB() (*gorm.DB, error) {
DBMS := "mysql"
mySqlConfig := &mysql.Config{
User: "root",
Passwd: "root",
Net: "tcp",
Addr: "127.0.0.1:3306",
DBName: "firebase-authentication-app",
AllowNativePasswords: true,
Params: map[string]string{
"parseTime": "true",
},
}
return gorm.Open(DBMS, mySqlConfig.FormatDSN())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment