forked from ketch-com/orlop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.go
More file actions
34 lines (26 loc) · 892 Bytes
/
env.go
File metadata and controls
34 lines (26 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package orlop
import "os"
// EnvironmentKey is the environment variable we look for to set the environment
const EnvironmentKey = "SWITCHBIT_ENVIRONMENT"
// Environment is a defined environment
type Environment string
// IsLocal returns true if the environment is not defined (aka local)
func (e Environment) IsLocal() bool {
return e == ""
}
// IsProduction returns true if the environment is the production environment.
func (e Environment) IsProduction() bool {
return e == "prod" || e == "production"
}
// IsTest returns true if the environment is the test environment
func (e Environment) IsTest() bool {
return e == "test"
}
// String returns a string version of the environment.
func (e Environment) String() string {
return string(e)
}
// Env returns the environment from the environment variables
func Env() Environment {
return Environment(os.Getenv(EnvironmentKey))
}