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