-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_test.go
44 lines (36 loc) · 979 Bytes
/
example_test.go
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
35
36
37
38
39
40
41
42
43
44
package denv_test
import (
"fmt"
"os"
"github.com/nao1215/denv"
)
func Example() {
if err := os.Setenv("APP_ENV", denv.Staging); err != nil {
fmt.Println("Error setting environment variable:", err)
return
}
// Create a new Env instance.
env, err := denv.NewEnv()
if err != nil {
fmt.Println("Error creating environment:", err)
return
}
// Print the current environment.
fmt.Printf("Current environment: %s\n", env.String())
// Check if it's the development environment.
if env.IsDevelopment() {
fmt.Println("This is the development environment.")
} else {
fmt.Println("This is not the development environment.")
}
// Check if it's the production environment.
if env.IsProduction() {
fmt.Println("This is the production environment.")
} else {
fmt.Println("This is not the production environment.")
}
// Output:
// Current environment: staging
// This is not the development environment.
// This is not the production environment.
}