forked from NdoleStudio/httpsms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
38 lines (32 loc) · 777 Bytes
/
Copy pathconfig.go
File metadata and controls
38 lines (32 loc) · 777 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
35
36
37
38
package di
import (
"log"
"os"
"strings"
"github.com/joho/godotenv"
)
// LoadEnv will read your .env file(s) and load them into ENV for this process.
func LoadEnv(filenames ...string) {
err := godotenv.Load(filenames...)
if err != nil {
log.Fatalf("Fatal: cannot load .env file: %v", err)
}
}
func getEnvWithDefault(key, defaultValue string) string {
value := os.Getenv(key)
if value == "" {
return defaultValue
}
return value
}
func splitCommaEnv(key, defaultValue string) []string {
value := getEnvWithDefault(key, defaultValue)
parts := strings.Split(value, ",")
result := make([]string, 0, len(parts))
for _, part := range parts {
if trimmed := strings.TrimSpace(part); trimmed != "" {
result = append(result, trimmed)
}
}
return result
}