init commit

This commit is contained in:
Stanislaw
2022-12-17 00:11:33 +01:00
parent eae5277f3d
commit 31d4d055ac
7 changed files with 375 additions and 0 deletions

27
main.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"os"
"github.com/joho/godotenv"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
func main() {
//line valid only on dev. ignore
godotenv.Load("local.env")
//database connection
db, err := gorm.Open(postgres.Open(os.Getenv("DATABASE_URL")), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
db.AutoMigrate(&Quote{},
&QuoteLine{})
//Init api
router := InitRouter()
err = router.Run(":2021")
}