Standard library / runtime
runtime.TypeAssertionError
Runtime error from a failed single-result type assertion. Prefer comma-ok for expected type mismatches. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
type TypeAssertionError struct {}Working Example
Example Snippetgo
package main
import ( "fmt" "runtime")
func main() { func() { defer func() { e, ok := recover().(*runtime.TypeAssertionError) fmt.Println(ok && e != nil && e.Error() != "") }() var x any = 42 _ = x.(string) }()}