NewEnv takes in environment string and returns a Env type. It does some "best-effort" normalization internally. For example, prod, PROD, production and PRODUCTION produces the same type. It is recommended to use one of "production", "staging", "development", "local", or "testing" as output to avoid
(env string)
| 59 | // For example, prod, PROD, production and PRODUCTION produces the same type. It is recommended to use one of |
| 60 | // "production", "staging", "development", "local", or "testing" as output to avoid unexpected outcome. |
| 61 | func NewEnv(env string) Env { |
| 62 | switch strings.ToLower(env) { |
| 63 | case "production", "prod", "online": |
| 64 | return EnvProduction |
| 65 | case "pre-prod", "staging": |
| 66 | return EnvStaging |
| 67 | case "development", "develop", "dev": |
| 68 | return EnvDevelopment |
| 69 | case "local": |
| 70 | return EnvLocal |
| 71 | case "testing", "test": |
| 72 | return EnvTesting |
| 73 | default: |
| 74 | return EnvUnknown |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // NewEnvFromConf reads the name of application from configuration's "env" entry. |
| 79 | func NewEnvFromConf(conf contract.ConfigUnmarshaler) Env { |
no outgoing calls