Skip to content

Instantly share code, notes, and snippets.

@krittawatcode
Last active December 12, 2020 05:10
Show Gist options
  • Save krittawatcode/4bb7436dd34c30c08ce7f6de2fbcc753 to your computer and use it in GitHub Desktop.
Save krittawatcode/4bb7436dd34c30c08ce7f6de2fbcc753 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
"github.com/krittawatcode/go-todo-clean-arch/databases"
"github.com/krittawatcode/go-todo-clean-arch/deliveries/routes"
"github.com/krittawatcode/go-todo-clean-arch/models"
)
var err error
func main() {
databases.DB, err = gorm.Open("mysql", databases.DbURL(databases.BuildDBConfig()))
if err != nil {
fmt.Println("statuse: ", err)
}
defer databases.DB.Close()
// run the migrations: todo struct
databases.DB.AutoMigrate(&models.Todo{})
//setup routes
r := routes.SetupRouter()
// running
r.Run(":8080")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment