Skip to content

runtime: can't recover #50512

@letian0805

Description

@letian0805

What version of Go are you using (go version)?

$ go version

Does this issue reproduce with the latest release?

version go1.16

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

package main

import (
    "fmt"
)

func main(){
    defer func() {
        test()
    }() 
    //defer test()  //if add this line, it will work
    panic("test")
}

func test() {
    if err := recover(); err != nil {
        fmt.Println(err)
    }   
}

What did you expect to see?

recovered

What did you see instead?

panic: test

goroutine 1 [running]:
main.main()
/home/letian/work/go/src/test/test.go:11 +0x5b
exit status 2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions