[go-nuts] idiomatic code to find, if executable exists in golang

2018-09-26 Thread Dave Cheney
Are you able to modify the original question. Why do you need to know if a binary exists? Presumably so you can execute it. If so then you can modify the original request and make the problem more tractable. -- You received this message because you are subscribed to the Google Groups "golang-

[go-nuts] idiomatic code to find, if executable exists in golang

2018-09-25 Thread Nilsocket
package main import ( "os" "os/exec" ) func main() { cmdName := os.Args[1] //either cmd or executable without arguments if _, err := exec.LookPath(cmdName); err != nil { if (err.(*exec.Error)).Err == exec.ErrNotFound { // executable doesn't exist, do some