Skip to content

Instantly share code, notes, and snippets.

@kjk
Created March 11, 2020 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjk/2a80bc3e48d7f36f3299367660a0aedd to your computer and use it in GitHub Desktop.
Save kjk/2a80bc3e48d7f36f3299367660a0aedd to your computer and use it in GitHub Desktop.
package main
// https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html
import (
"fmt"
"os/exec"
)
func checkExeExists(exe string) {
path, err := exec.LookPath(exe)
if err != nil {
fmt.Printf("didn't find '%s' executable\n", exe)
return
}
fmt.Printf("'%s' executable is '%s'\n", exe, path)
}
func main() {
checkExeExists("ls")
checkExeExists("ls2")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment