我怎样才能在recovery()中捕获runtime.errorString?

I try to catch the panic

func test(/*some input*/) (output string,err111 error) {
    defer func(){
        if err := recover(); err != nil {
            output = ""
            err111 = errors.New(err.(string))
        }
    }()
    ....
}

but goroutine tell me

interface conversion: interface {} is runtime.errorString, not string

how can I dump the recover() error and return it?

You cannot using type assertion like errors.New(err.(string)) cuz string is a underlying type which does not implement error interface.

So if you want to catch runtime.errorString panic. Maybe an unformal way is using reflection like :

if reflect.TypeOf(err).String() == "*errors.errorString" {
    // do something
}