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