MCPcopy
hub / github.com/usefathom/fathom / LoadEnv

Function LoadEnv

pkg/config/config.go:22–44  ·  view source on GitHub ↗

LoadEnv loads env values from the supplied file

(file string)

Source from the content-addressed store, hash-verified

20
21// LoadEnv loads env values from the supplied file
22func LoadEnv(file string) {
23 if file == "" {
24 log.Warn("Missing configuration file. Using defaults.")
25 return
26 }
27
28 absFile, _ := filepath.Abs(file)
29 _, err := os.Stat(absFile)
30 fileNotExists := os.IsNotExist(err)
31
32 if fileNotExists {
33 log.Warnf("Error reading configuration. File `%s` does not exist.", file)
34 return
35 }
36
37 log.Printf("Configuration file: %s", absFile)
38
39 // read file into env values
40 err = godotenv.Load(absFile)
41 if err != nil {
42 log.Fatalf("Error parsing configuration file: %s", err)
43 }
44}
45
46// Parse environment into a Config struct
47func Parse() *Config {

Callers 3

beforeFunction · 0.92
TestLoadEnvFunction · 0.85
TestDatabaseURLFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestLoadEnvFunction · 0.68
TestDatabaseURLFunction · 0.68