AppPath returns the absolute path of the application's binary.
()
| 28 | |
| 29 | // AppPath returns the absolute path of the application's binary. |
| 30 | func AppPath() string { |
| 31 | appPathOnce.Do(func() { |
| 32 | var err error |
| 33 | appPath, err = exec.LookPath(os.Args[0]) |
| 34 | if err != nil { |
| 35 | panic("look executable path: " + err.Error()) |
| 36 | } |
| 37 | |
| 38 | appPath, err = filepath.Abs(appPath) |
| 39 | if err != nil { |
| 40 | panic("get absolute executable path: " + err.Error()) |
| 41 | } |
| 42 | }) |
| 43 | |
| 44 | return appPath |
| 45 | } |
| 46 | |
| 47 | var ( |
| 48 | workDir string |
no test coverage detected