MCPcopy Index your code
hub / github.com/perkeep/perkeep / LookPathGopath

Function LookPathGopath

internal/osutil/paths.go:448–465  ·  view source on GitHub ↗

LookPathGopath uses exec.LookPath to find binName, and then falls back to looking in $GOPATH/bin.

(binName string)

Source from the content-addressed store, hash-verified

446// LookPathGopath uses exec.LookPath to find binName, and then falls back to
447// looking in $GOPATH/bin.
448func 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}

Callers 7

RunCommandMethod · 0.92
RunCommandMethod · 0.92
RunCommandMethod · 0.92
runPrecommitHookMethod · 0.92
RunCommandMethod · 0.92
LookPathMethod · 0.92
LookPathMethod · 0.92

Calls 3

goPathBinDirFunction · 0.70
LookPathMethod · 0.65
StatMethod · 0.65

Tested by

no test coverage detected