From 9f8003e8c9d09b5efb92b05c997cae051fd3ac71 Mon Sep 17 00:00:00 2001 From: handlerug Date: Wed, 28 Apr 2021 17:40:53 +0700 Subject: [PATCH] Absolutize the path to config file --- util/config.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util/config.go b/util/config.go index e6c5fe9..6b1212e 100644 --- a/util/config.go +++ b/util/config.go @@ -2,6 +2,7 @@ package util import ( "log" + "path/filepath" "strconv" "github.com/go-ini/ini" @@ -62,8 +63,13 @@ func ReadConfigFile(path string) { } if path != "" { + path, err := filepath.Abs(path) + if err != nil { + log.Fatalf("cannot expand config file path: %s", err) + } + log.Println("Loading config at", path) - err := ini.MapTo(cfg, path) + err = ini.MapTo(cfg, path) if err != nil { log.Fatal(err) }