We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e7be5bb commit f2d5451Copy full SHA for f2d5451
packages/shared/pkg/env/env.go
@@ -1,6 +1,9 @@
1
package env
2
3
-import "os"
+import (
4
+ "os"
5
+ "strconv"
6
+)
7
8
var environment = GetEnv("ENVIRONMENT", "local")
9
@@ -23,3 +26,16 @@ func GetEnv(key, defaultValue string) string {
23
26
}
24
27
return value
25
28
29
+
30
+func GetEnvAsInt(key string, defaultValue int) (int, error) {
31
+ if v := os.Getenv(key); v != "" {
32
+ value, err := strconv.Atoi(v)
33
+ if err != nil {
34
+ return defaultValue, err
35
+ }
36
37
+ return value, nil
38
39
40
+ return defaultValue, nil
41
+}
0 commit comments