fix: allow load config file

This commit is contained in:
2024-05-06 17:19:58 +02:00
parent 2255b1f158
commit 2ff3299ad7
2 changed files with 26 additions and 3 deletions

10
main.go
View File

@@ -15,9 +15,13 @@ import (
)
func main() {
// Get root path
_, filename, _, _ := runtime.Caller(0)
cfg, err := config.LoadConfig(path.Join(path.Dir(filename), "configs", "app.yml"))
cfgFile := os.Getenv("CONFIG_FILE")
if cfgFile == "" {
// Get root path
_, filename, _, _ := runtime.Caller(0)
cfgFile = path.Join(path.Dir(filename), "configs", "app.yml")
}
cfg, err := config.LoadConfig(cfgFile)
if err != nil {
log.Fatalf("Error loading config: %v", err)
}