Last active
May 22, 2021 09:55
-
-
Save dipeshhkc/5403fbfaa5f0dde5028d7fd04a039ddf to your computer and use it in GitHub Desktop.
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
USER := "root" | |
PASS := "root" | |
HOST := "localhost" | |
PORT := "3306" | |
DBNAME := "test" | |
url := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", USER, PASS, HOST, PORT, DBNAME) | |
db, err := gorm.Open(mysql.Open(url), &gorm.Config{Logger: newLogger}) | |
if err != nil { | |
panic(err) | |
} | |
db.AutoMigrate(&Post{}, &Comment{}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment