diff --git a/.gitignore b/.gitignore index 84146d5..6040264 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .air.toml .env +.env-dev tmp/* logs/* !logs/.gitkeep diff --git a/main.go b/main.go index fd1f7b4..4b9c956 100644 --- a/main.go +++ b/main.go @@ -26,14 +26,25 @@ var resources embed.FS func main() { app := core.New() basePath, err := os.Getwd() + runMode := "dev" + if len(os.Args) > 1 { + if os.Args[1] == "prod" || os.Args[1] == "dev" { + runMode = os.Args[1] + } + } if err != nil { log.Fatal("error getting current working dir") } app.SetBasePath(basePath) + app.SetRunMode(runMode) app.MakeDirs("logs", "storage", "storage/sqlite", "tls") // Handle the reading of the .env file if config.GetEnvFileConfig().UseDotEnvFile { - envVars, err := godotenv.Read(".env") + envfile := ".env-dev" + if runMode == "prod" { + envfile = ".env" + } + envVars, err := godotenv.Read(envfile) if err != nil { log.Fatal("Error loading .env file") }