MCPcopy
hub / github.com/abiosoft/colima / Executable

Function Executable

util/osutil/os.go:54–86  ·  view source on GitHub ↗

Executable returns the path name for the executable that started the current process.

()

Source from the content-addressed store, hash-verified

52// Executable returns the path name for the executable that started
53// the current process.
54func Executable() string {
55 e, err := func(s string) (string, error) {
56 // prioritize env var in case this is a nested process
57 if e := os.Getenv(EnvColimaBinary); e != "" {
58 return e, nil
59 }
60
61 if filepath.IsAbs(s) {
62 return s, nil
63 }
64
65 e, err := exec.LookPath(s)
66 if err != nil {
67 return "", fmt.Errorf("error looking up '%s' in PATH: %w", s, err)
68 }
69
70 abs, err := filepath.Abs(e)
71 if err != nil {
72 return "", fmt.Errorf("error computing absolute path of '%s': %w", e, err)
73 }
74
75 return abs, nil
76 }(os.Args[0])
77
78 if err != nil {
79 // this should never happen, thereby it is safe to do
80 logrus.Traceln(fmt.Errorf("cannot detect current running executable: %w", err))
81 logrus.Traceln("falling back to first CLI argument")
82 return os.Args[0]
83 }
84
85 return e
86}
87
88// Socket is a unix socket
89type Socket string

Callers 5

NewFunction · 0.92
nerdctl.goFile · 0.92
RunningMethod · 0.92
StartMethod · 0.92
StopMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected