From 914544586886b6262ec29858c5023c9b165f617a Mon Sep 17 00:00:00 2001 From: KostLinux Date: Wed, 17 Apr 2024 21:23:57 +0300 Subject: [PATCH] Refactored configuration files and added DEBUG_MODE environment variable --- .env.example | 16 ++++++++-------- .gitignore | 3 ++- Makefile | 5 +++++ README.md | 1 + main.go | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index 8789878..e353c1e 100644 --- a/.env.example +++ b/.env.example @@ -1,13 +1,13 @@ # APP APP_PORT=8000 -APP_HOST="localhost" +APP_HOST=localhost +DEBUG_MODE=true # API -API_PATH="/api/v1/" +API_PATH=/api/v1/ # MISC -FORCE_SSL="false" -GO_ENV="development" +FORCE_SSL=false # External Services @@ -15,8 +15,8 @@ GO_ENV="development" ### To enable PSQL connection, set PSQL_ENABLED true PSQL_ENABLED=false -POSTGRES_HOST="localhost" +POSTGRES_HOST=localhost POSTGRES_PORT=5432 -POSTGRES_USER="postgres" -POSTGRES_PASSWORD="postgres" -POSTGRES_DB="postgres" +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres +POSTGRES_DB=postgres \ No newline at end of file diff --git a/.gitignore b/.gitignore index eeacc5d..7dfab38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .env -vendor/ \ No newline at end of file +vendor/ +bin/main \ No newline at end of file diff --git a/Makefile b/Makefile index 774e0e1..eb0f82a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ +_DEFAULT_GOAL := run + include .env +build: + go build -o bin/main main.go + run: go run main.go diff --git a/README.md b/README.md index a86b372..c08c21b 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Feel free to fork the project and use it as a starting point for your next web a ## Folder structure +- `bin`- Binary folder for the web application. Mostly used for different scripts or when compiling Go code - `docs` - Web Application documentation - `handlers` - Controller component (in MVC architecture) folder. Contain the logic for the web application (e.g. API, Error Handling, etc.) - `handlers/api` - API request and response handling diff --git a/main.go b/main.go index 96e68d9..6e0b374 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ func main() { log.Fatalf("Error loading .env file") } - if os.Getenv("APP_ENV") == "production" && os.Getenv("DEBUG_MODE") != "true" { + if os.Getenv("DEBUG_MODE") != "true" { gin.SetMode(gin.ReleaseMode) }