Skip to content

Commit 4574340

Browse files
dgryskideadprogram
authored andcommitted
os: handle relative and abs paths in Executable()
1 parent 5428bfd commit 4574340

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/os/executable_darwin.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,14 @@ package os
66
func runtime_executable_path() string
77

88
func Executable() (string, error) {
9-
return runtime_executable_path(), nil
9+
p := runtime_executable_path()
10+
if p != "" && p[0] == '/' {
11+
// absolute path
12+
return p, nil
13+
}
14+
cwd, err := Getwd()
15+
if err != nil {
16+
return "", err
17+
}
18+
return joinPath(cwd, p), nil
1019
}

0 commit comments

Comments
 (0)