Created
March 11, 2020 23:01
-
-
Save kjk/2a80bc3e48d7f36f3299367660a0aedd to your computer and use it in GitHub Desktop.
check executable exists example for https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html (made with https://codeeval.dev)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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