From b7f5704b2b277e54f8b21baa5345c24da0f29668 Mon Sep 17 00:00:00 2001 From: mikestefanello Date: Tue, 14 Dec 2021 20:17:09 -0500 Subject: [PATCH] Cleanup environment naming. --- config/config.go | 20 ++++++++++---------- routes/routes_test.go | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config/config.go b/config/config.go index 4e13bd8..89aab02 100644 --- a/config/config.go +++ b/config/config.go @@ -14,15 +14,15 @@ const ( StaticPrefix = "files" ) -type Env string +type Environment string const ( - EnvLocal Env = "local" - EnvTest Env = "test" - EnvDevelop Env = "dev" - EnvStaging Env = "staging" - EnvQA Env = "qa" - EnvProduction Env = "prod" + EnvLocal Environment = "local" + EnvTest Environment = "test" + EnvDevelop Environment = "dev" + EnvStaging Environment = "staging" + EnvQA Environment = "qa" + EnvProduction Environment = "prod" ) type ( @@ -47,7 +47,7 @@ type ( // AppConfig stores application configuration AppConfig struct { Name string `env:"APP_NAME,default=Goweb"` - Environment Env `env:"APP_ENV,default=local"` + Environment Environment `env:"APP_ENVIRONMENT,default=local"` EncryptionKey string `env:"APP_ENCRYPTION_KEY,default=?E(G+KbPeShVmYq3t6w9z$C&F)J@McQf"` Timeout time.Duration `env:"APP_TIMEOUT,default=20s"` } @@ -87,8 +87,8 @@ func GetConfig() (Config, error) { return cfg, err } -func SwitchEnv(env Env) { - if err := os.Setenv("APP_ENV", string(env)); err != nil { +func SwitchEnvironment(env Environment) { + if err := os.Setenv("APP_ENVIRONMENT", string(env)); err != nil { panic(err) } } diff --git a/routes/routes_test.go b/routes/routes_test.go index 54df035..7dfcbbe 100644 --- a/routes/routes_test.go +++ b/routes/routes_test.go @@ -23,7 +23,7 @@ var ( func TestMain(m *testing.M) { // Set the environment to test - config.SwitchEnv(config.EnvTest) + config.SwitchEnvironment(config.EnvTest) // Start a test HTTP server c = container.NewContainer()