Skip to content

Instantly share code, notes, and snippets.

@ssaumyaranjan7
Created June 9, 2019 07:31
Show Gist options
  • Save ssaumyaranjan7/94d148880b6882e4df769b5512062985 to your computer and use it in GitHub Desktop.
Save ssaumyaranjan7/94d148880b6882e4df769b5512062985 to your computer and use it in GitHub Desktop.
This is the database configuration file for MySQL.
package config
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
var (
db * gorm.DB
)
func Connect() {
// Please define your user name and password for my sql.
d, err := gorm.Open("mysql", "root:root@/simplerest?charset=utf8&parseTime=True&loc=Local")
if err != nil{
panic(err)
}
db = d
}
func GetDB() *gorm.DB {
return db
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment