Skip to content

Instantly share code, notes, and snippets.

@mohashari
Last active June 21, 2018 15:22
Show Gist options
  • Select an option

  • Save mohashari/0accd7221baa223b8c88aa57dba6a0ea to your computer and use it in GitHub Desktop.

Select an option

Save mohashari/0accd7221baa223b8c88aa57dba6a0ea to your computer and use it in GitHub Desktop.
package main
import (
"github.com/jinzhu/gorm"
"github.com/gin-gonic/gin"
_ "github.com/jinzhu/gorm/dialects/mysql"
"net/http"
)
var db *gorm.DB
func init() {
var err error
db, err =
gorm.Open("mysql", "root:welcome1@tcp(127.0.0.1:3306)/golang?charset=utf8&parseTime=True&loc=Local")
if err != nil {
panic("Gagal Conect Ke Database")
}
db.AutoMigrate(&student{})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment