-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Open
Description
The name of an executable could be found in different paths (e.g, different versions of the same executable). LookPath is internally used to find what and retrieves something to run. Thus, I don't feel strong to modify what it retrieves to accomplish this purpose.
Instead, I've thought about a new function called LookPaths to give all possible matches of the wanted executable's name rather than the first matched occurrence.
For example, in case want all possible paths of bash:
package main
import (
"fmt"
"log"
"os/exec"
)
func main() {
path, err := exec.LookPaths("bash")
if err != nil {
log.Fatal(err)
}
fmt.Println(path)
// Sample Output: [/bin/bash /usr/bin/bash /usr/local/bin/bash]
}In regards to an archaic design of LookPaths:
func LookPaths(file string) ([]string, error) {
// ...
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Incoming