added in config loading from file then ENV

This commit is contained in:
2021-08-14 22:51:27 -04:00
parent fe7443daaa
commit e102b7cc18
6 changed files with 68 additions and 3 deletions

14
main.go
View File

@@ -2,12 +2,22 @@ package main
import (
"fmt"
"os"
"log"
"github.com/gofiber/fiber/v2"
)
type Server struct {
Config *Config
}
func main() {
server := Server{}
err := LoadConfig(&server)
if err != nil {
log.Fatal("Unable to load in config file: ", err)
}
fmt.Println("Server: ", server.Config)
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
@@ -15,5 +25,5 @@ func main() {
})
// fmt.Println("Port listen on: ", os.Getenv("PORT"))
// fmt.Println("Timezone is: ", os.Getenv("TZ"))
app.Listen(fmt.Sprintf(":%s", os.Getenv("PORT")))
app.Listen(fmt.Sprintf(":%s", server.Config.Server.Port))
}