-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (40 loc) · 947 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
49
package main
import (
"fmt"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/log"
"github.com/joho/godotenv"
"os"
"soybean-admin-go/app/database"
"soybean-admin-go/app/router"
"time"
)
// @title soybean-admin-go Admin App
// @version 1.0
// @description This is an API for soybean-admin-go Application
// @contact.name hxl
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
//
// @BasePath /api
func main() {
var Loc, _ = time.LoadLocation("Asia/Shanghai")
time.Local = Loc
// 加载配置文件
err := godotenv.Load()
if err != nil {
log.Fatal(err)
}
// 连接数据库
err = database.ConnectDB()
if err != nil {
log.Fatal(err)
panic("failed to connect database")
}
app := fiber.New()
router.Initalize(app)
// 从环境变量中获取端口号
port := fmt.Sprintf(":%s", os.Getenv("PORT"))
log.Fatal(app.Listen(port))
}