Skip to content

Instantly share code, notes, and snippets.

@dipeshhkc
Last active May 22, 2021 09:55
Show Gist options
  • Save dipeshhkc/5403fbfaa5f0dde5028d7fd04a039ddf to your computer and use it in GitHub Desktop.
Save dipeshhkc/5403fbfaa5f0dde5028d7fd04a039ddf to your computer and use it in GitHub Desktop.
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