From c8d0bbb5b54f5cec3ebb245f9a21d8a94b3bd944 Mon Sep 17 00:00:00 2001 From: Bobby <30593201+luciferreeves@users.noreply.github.com> Date: Thu, 15 Jan 2026 15:53:17 +0530 Subject: Add initial project structure with Go Fiber framework and environment configuration --- config/config.go | 22 ++++++++++++++++++++++ config/env.go | 8 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 config/config.go create mode 100644 config/env.go (limited to 'config') diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..85f947c --- /dev/null +++ b/config/config.go @@ -0,0 +1,22 @@ +package config + +import ( + "cafe/utils/env" + "log" + + "github.com/joho/godotenv" +) + +var ( + Server server +) + +func init() { + if err := godotenv.Load(); err != nil { + log.Println("No .env file found, using environment variables") + } + + if err := env.Parse(&Server); err != nil { + log.Fatalf("Failed to parse ServerConfig: %v", err) + } +} diff --git a/config/env.go b/config/env.go new file mode 100644 index 0000000..bdac2b4 --- /dev/null +++ b/config/env.go @@ -0,0 +1,8 @@ +package config + +type server struct { + Host string `env:"SERVER_HOST" default:"localhost"` + Port int `env:"SERVER_PORT" default:"8080"` + AppSecret string `env:"APP_SECRET" default:"mysecret"` + DevMode bool `env:"DEV_MODE" default:"true"` +} -- cgit v1.2.3