Files

27 lines
590 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"log"
"github.com/joho/godotenv"
"mengpost-backend/config"
"mengpost-backend/database"
"mengpost-backend/router"
"mengpost-backend/services"
)
func main() {
// 从工作目录加载 .envKEY=value缺失则忽略仍可用系统环境变量。
_ = godotenv.Load()
cfg := config.Load()
services.SetAppConfig(cfg)
database.Init(cfg.DBPath)
r := router.New(cfg)
log.Printf("萌邮 MengPost backend listening on :%s (token=%s)", cfg.Port, cfg.Token)
if err := r.Run(":" + cfg.Port); err != nil {
log.Fatal(err)
}
}