exec.go (349B)
1 package internal 2 3 import ( 4 "fmt" 5 "os/exec" 6 ) 7 8 type CommandNotFound string 9 10 func (e CommandNotFound) Error() string { 11 return fmt.Sprintf("command '%s' is missing and must be present for operation", string(e)) 12 } 13 14 func RequireCommand(cmd string) error { 15 _, err := exec.LookPath(cmd) 16 if err != nil { 17 return CommandNotFound(cmd) 18 } 19 20 return nil 21 }