Standard library / os/exec
os/exec.Error.Unwrap()
Returns the underlying executable lookup error for errors.Is or errors.As. 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) Unwrap() errorReturn Value
error
Returns the underlying executable lookup error for errors.Is or errors.As.
Working Example
Example Snippetgo
package main
import ( "fmt" "os/exec")
func must(e error) { if e != nil { panic(e) }}func main() { e := &exec.Error{Name: "sample", Err: exec.ErrNotFound} fmt.Println(e.Unwrap() == exec.ErrNotFound)}