-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (30 loc) · 817 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 (
_ "github.com/TheBeege/mentor-me-api/routers"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"fmt"
_ "github.com/lib/pq"
"os"
"time"
)
func init() {
dbHost := os.Getenv("dbhost")
dbUser := os.Getenv("dbuser")
dbPass := os.Getenv("dbpass")
dbDatabase := os.Getenv("dbdatabase")
conString := fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable",
dbHost, dbUser, dbPass, dbDatabase)
orm.RegisterDriver("postgres", orm.DRPostgres)
orm.RegisterDataBase("default", "postgres", conString)
orm.SetMaxIdleConns("default", 30)
// Set to UTC time
orm.DefaultTimeLoc = time.UTC
}
func main() {
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
beego.Run()
}