summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-01-15 15:53:17 +0530
committerBobby <[email protected]>2026-01-15 15:53:17 +0530
commitc8d0bbb5b54f5cec3ebb245f9a21d8a94b3bd944 (patch)
tree6a5c2500da90253ad07a0d5192071bb77f093d36 /config
downloadcafe-c8d0bbb5b54f5cec3ebb245f9a21d8a94b3bd944.tar.xz
cafe-c8d0bbb5b54f5cec3ebb245f9a21d8a94b3bd944.zip
Add initial project structure with Go Fiber framework and environment configuration
Diffstat (limited to 'config')
-rw-r--r--config/config.go22
-rw-r--r--config/env.go8
2 files changed, 30 insertions, 0 deletions
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"`
+}