Created
June 9, 2019 07:31
-
-
Save ssaumyaranjan7/94d148880b6882e4df769b5512062985 to your computer and use it in GitHub Desktop.
This is the database configuration file for MySQL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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