-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (41 loc) · 954 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
48
package main
import (
"net/http"
"os"
"time"
"github.com/charmbracelet/log"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
jsoniter "github.com/json-iterator/go"
"gorm.io/gorm"
)
var logger = log.NewWithOptions(os.Stderr, log.Options{
ReportCaller: false,
ReportTimestamp: true,
TimeFormat: time.TimeOnly,
Level: log.DebugLevel,
Prefix: "Backend",
})
var (
db *gorm.DB
api *gin.Engine
isDevelopment bool
json = jsoniter.ConfigCompatibleWithStandardLibrary
request = &http.Client{}
)
func main() {
if os.Getenv("MODE") == "PRODUCTION" {
logger.Info("Running in PRODUCTION mode.")
gin.SetMode(gin.ReleaseMode)
} else {
err := godotenv.Load()
logger.Info("Running in DEVELOPMENT mode.")
isDevelopment = true
if err != nil {
logger.Fatalf("Failed to load .env file (Does it exist?): %v", err)
return
}
}
InitializeORM()
InitializeAPI()
}