Standard library / os/exec
os/exec.ErrNotFound
Indicates executable search did not find the requested program in PATH. Check the dependency and trusted search path. Example intended for Linux/AMD64 with Go 1.23.2 in a disposable working directory; other platforms may differ. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
var ErrNotFound errorWorking Example
Example Snippetgo
package main
import ( "errors" "fmt" "os" "os/exec")
func must(e error) { if e != nil { panic(e) }}func main() { must(os.Setenv("PATH", "/bytemind/nonexistent")) _, e := exec.LookPath("bytemind-missing") fmt.Println(errors.Is(e, exec.ErrNotFound))}