LookPathGopath uses exec.LookPath to find binName, and then falls back to looking in $GOPATH/bin.
(binName string)
| 446 | // LookPathGopath uses exec.LookPath to find binName, and then falls back to |
| 447 | // looking in $GOPATH/bin. |
| 448 | func LookPathGopath(binName string) (string, error) { |
| 449 | binPath, err := exec.LookPath(binName) |
| 450 | if err == nil { |
| 451 | return binPath, nil |
| 452 | } |
| 453 | binDir, err := goPathBinDir() |
| 454 | if err != nil { |
| 455 | return "", fmt.Errorf("command %q not found in $PATH, and could not look in $GOPATH/bin because %v", binName, err) |
| 456 | } |
| 457 | binPath = filepath.Join(binDir, binName) |
| 458 | if runtime.GOOS == "windows" { |
| 459 | binPath += ".exe" |
| 460 | } |
| 461 | if _, err := os.Stat(binPath); err != nil { |
| 462 | return "", err |
| 463 | } |
| 464 | return binPath, nil |
| 465 | } |
no test coverage detected