Standard library / os/exec

os/exec.Error

Describes an executable lookup error with the requested name and underlying cause. It supports error unwrapping. 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
type Error struct {  Name string  Err error}

Working Example

Example Snippetgo
package main
import (  "errors"  "fmt"  "os/exec")
func must(e error) {  if e != nil {    panic(e)  }}func main() {  var e error = &exec.Error{Name: "sample", Err: exec.ErrNotFound}  fmt.Println(errors.Is(e, exec.ErrNotFound))}
Go Reference