...
Source file src/os/executable_procfs.go
1
2
3
4
5
6
7 package os
8
9 import (
10 "errors"
11 "runtime"
12 )
13
14
15
16
17 var executablePath, executablePathErr = func() (string, error) {
18 var procfn string
19 switch runtime.GOOS {
20 default:
21 return "", errors.New("Executable not implemented for " + runtime.GOOS)
22 case "linux", "android":
23 procfn = "/proc/self/exe"
24 case "netbsd":
25 procfn = "/proc/curproc/exe"
26 case "dragonfly":
27 procfn = "/proc/curproc/file"
28 }
29 return Readlink(procfn)
30 }()
31
32 func executable() (string, error) {
33 return executablePath, executablePathErr
34 }
35
View as plain text