-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (37 loc) · 927 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"github.com/ExeCiety/go-fiber-todo-list/utils/enums"
"log"
"os"
"github.com/ExeCiety/go-fiber-todo-list/cmd"
"github.com/ExeCiety/go-fiber-todo-list/db"
pkgRouters "github.com/ExeCiety/go-fiber-todo-list/pkg/routers"
"github.com/ExeCiety/go-fiber-todo-list/utils"
"github.com/gofiber/fiber/v2"
"github.com/joho/godotenv"
)
func main() {
// Set root path
cwd, _ := os.Getwd()
utils.SetRootPath(cwd + "/")
// Load .env file
if err := godotenv.Load(); err != nil {
log.Fatal("Error loading .env file")
return
}
// Execute cmd tool
cmd.Execute()
// Connect DB
db.Connect()
// Create Fiber app
app := fiber.New()
// Set Routers
pkgRouters.SetRouter(app)
// Listen to port
port := utils.GetEnvValue("APP_PORT", enums.DefaultAppPort)
if err := app.Listen(fmt.Sprintf(":%s", port)); err != nil {
log.Fatalf("Error when listen to port 3000: %v", err)
return
}
}