-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmain.go
34 lines (27 loc) · 802 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
package main
import (
"gin-boilerplate/config"
"gin-boilerplate/infra/database"
"gin-boilerplate/infra/logger"
"gin-boilerplate/migrations"
"gin-boilerplate/routers"
"github.com/spf13/viper"
"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", router.Run(config.ServerConfig()))
}