fix when running from absolute path
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-13 16:48:17 +10:00
parent d3b9b22a09
commit 49ddd56e3d
3 changed files with 4 additions and 3 deletions

View File

@@ -18,11 +18,11 @@ func GetFilePath(path string) string {
// check if filename exists
if _, err := os.Stat(path); os.IsNotExist((err)) {
slog.Info("File '%s' not found, searching in same directory as binary", path)
slog.Info("File not found, searching in same directory as binary", "filename", path)
// if not, check that it exists in the same directory as the currently executing binary
ex, err2 := os.Executable()
if err2 != nil {
slog.Error("Error determining binary path : '%s'", err)
slog.Error("Error determining binary path", "error", err)
return ""
}
binaryPath := filepath.Dir(ex)