Source file
src/os/executable_darwin.go
1
2
3
4
5 package os
6
7 import (
8 "errors"
9 _ "unsafe"
10 )
11
12
13 var executablePath string
14
15 var initCwd, initCwdErr = Getwd()
16
17 func executable() (string, error) {
18 ep := executablePath
19 if len(ep) == 0 {
20 return ep, errors.New("cannot find executable path")
21 }
22 if ep[0] != '/' {
23 if initCwdErr != nil {
24 return ep, initCwdErr
25 }
26 if len(ep) > 2 && ep[0:2] == "./" {
27
28 ep = ep[2:]
29 }
30 ep = initCwd + "/" + ep
31 }
32 return ep, nil
33 }
34
View as plain text