Lint check adjustments.

This commit is contained in:
mikestefanello 2022-02-10 08:56:07 -05:00
parent 0cb52b6e12
commit 1809b154e3
18 changed files with 120 additions and 92 deletions

View file

@ -21,21 +21,32 @@ const (
StaticPrefix = "files"
)
type Environment string
type environment string
const (
EnvLocal Environment = "local"
EnvTest Environment = "test"
EnvDevelop Environment = "dev"
EnvStaging Environment = "staging"
EnvQA Environment = "qa"
EnvProduction Environment = "prod"
// EnvLocal represents the local environment
EnvLocal environment = "local"
// EnvTest represents the test environment
EnvTest environment = "test"
// EnvDevelop represents the development environment
EnvDevelop environment = "dev"
// EnvStaging represents the staging environment
EnvStaging environment = "staging"
// EnvQA represents the qa environment
EnvQA environment = "qa"
// EnvProduction represents the production environment
EnvProduction environment = "prod"
)
// SwitchEnvironment sets the environment variable used to dictate which environment the application is
// currently running in.
// This must be called prior to loading the configuration in order for it to take effect.
func SwitchEnvironment(env Environment) {
func SwitchEnvironment(env environment) {
if err := os.Setenv("APP_ENVIRONMENT", string(env)); err != nil {
panic(err)
}
@ -68,7 +79,7 @@ type (
// AppConfig stores application configuration
AppConfig struct {
Name string `env:"APP_NAME,default=Pagoda"`
Environment Environment `env:"APP_ENVIRONMENT,default=local"`
Environment environment `env:"APP_ENVIRONMENT,default=local"`
// THIS MUST BE OVERRIDDEN ON ANY LIVE ENVIRONMENTS
EncryptionKey string `env:"APP_ENCRYPTION_KEY,default=?E(G+KbPeShVmYq3t6w9z$C&F)J@McQf"`
Timeout time.Duration `env:"APP_TIMEOUT,default=20s"`

View file

@ -11,7 +11,7 @@ func TestGetConfig(t *testing.T) {
_, err := GetConfig()
require.NoError(t, err)
var env Environment
var env environment
env = "abc"
SwitchEnvironment(env)
cfg, err := GetConfig()