inspectRuntime tries to find the base executable directory and how it was run. note: we are using os.Args[0] and not os.Executable() since it could break existing aliased binaries (eg. the community maintained homebrew package)
()
| 296 | // note: we are using os.Args[0] and not os.Executable() since it could |
| 297 | // break existing aliased binaries (eg. the community maintained homebrew package) |
| 298 | func inspectRuntime() (baseDir string, withGoRun bool) { |
| 299 | if osutils.IsProbablyGoRun() { |
| 300 | // probably ran with go run |
| 301 | withGoRun = true |
| 302 | baseDir, _ = os.Getwd() |
| 303 | } else { |
| 304 | // probably ran with go build |
| 305 | withGoRun = false |
| 306 | baseDir = filepath.Dir(os.Args[0]) |
| 307 | } |
| 308 | return |
| 309 | } |
| 310 | |
| 311 | // newErrWriter returns a red colored stderr writter. |
| 312 | func newErrWriter() *coloredWriter { |
no test coverage detected
searching dependent graphs…