os: handle relative and abs paths in Executable()

This commit is contained in:
Damian Gryski
2025-04-30 11:36:03 -07:00
committed by Ron Evans
parent 5428bfd270
commit 45743406d0
+10 -1
View File
@@ -6,5 +6,14 @@ package os
func runtime_executable_path() string
func Executable() (string, error) {
return runtime_executable_path(), nil
p := runtime_executable_path()
if p != "" && p[0] == '/' {
// absolute path
return p, nil
}
cwd, err := Getwd()
if err != nil {
return "", err
}
return joinPath(cwd, p), nil
}