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