Standard library / os/exec

os/exec.Error.Error()

Returns descriptive executable lookup failure text. Inspect the error type or wrapped error rather than parsing prose. 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
func (e *Error) Error() string

Return Value

string

Returns descriptive executable lookup failure text.

Working Example

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