Standard library / runtime

runtime.PanicNilError.Error()

Return the diagnostic for panic(nil) under default Go 1.21+ semantics. Do not parse diagnostic text as a stable protocol. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (*PanicNilError) Error() string

Return Value

string

Diagnostic string for panic(nil).

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime")
func main() {  func() {    defer func() { r, ok := recover().(*runtime.PanicNilError); fmt.Println(ok && r != nil && r.Error() != "") }()    panic(nil)  }()}
Go Reference