generated from akmamun/gin-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
35 lines (28 loc) · 831 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
package main
import (
"chi-boilerplate/config"
"chi-boilerplate/infra/database"
"chi-boilerplate/infra/logger"
"chi-boilerplate/migrations"
"chi-boilerplate/routers"
"github.com/spf13/viper"
"net/http"
"time"
)
func main() {
//set timezone
viper.SetDefault("SERVER_TIMEZONE", "Asia/Dhaka")
loc, _ := time.LoadLocation(viper.GetString("SERVER_TIMEZONE"))
time.Local = loc
if err := config.SetupConfig(); err != nil {
logger.Fatalf("config SetupConfig() error: %s", err)
}
masterDSN, replicaDSN := config.DbConfiguration()
if err := database.DbConnection(masterDSN, replicaDSN); err != nil {
logger.Fatalf("database DbConnection error: %s", err)
}
//later separate migration
migrations.Migrate()
router := routers.SetupRoute()
logger.Fatalf("%v", http.ListenAndServe(config.ServerConfig(), router))
}