see https://go101.org/article/panic-and-recover-more.html for detailed
explanations.
On Thursday, July 18, 2019 at 12:52:13 PM UTC+8, ZPL wrote:
>
> Sorry for the bad formatting.
>
> > recover must be called directly by a deferred function
> func logPanic() {
> defer func() {
> if err :=
You could try it this way if you really need a separate function.
https://play.golang.org/p/V-ysjWbZ2X5
On Thu, 2019-07-18 at 12:51 +0800, ZP L wrote:
> Sorry for the bad formatting.
>
> > recover must be called directly by a deferred function
>
> func logPanic() {
> defer func() {
> if
The defer is not being run directly as a result of the panic.
>From the spec:
> The recover function allows a program to manage behavior of a
> panicking goroutine. Suppose a function G defers a function D that
> calls recover and a panic occurs in a function on the same goroutine
> in which G
On Wed, Jul 17, 2019 at 9:51 PM ZP L wrote:
>
> Sorry for the bad formatting.
>
> > recover must be called directly by a deferred function
> func logPanic() {
> defer func() {
> if err := recover(); err != nil {
>fmt.Println("got panic")
>return
> }
> }()
> }
>
Sorry for the bad formatting.
> recover must be called directly by a deferred function
func logPanic() {
defer func() {
if err := recover(); err != nil {
fmt.Println("got panic")
return
}
}()
}
This still not working.
>From
On Wed, Jul 17, 2019 at 5:11 AM Tamás Gulácsi wrote:
>
> The "recover()" call must be in the deferred part.
Yes, as the spec says, recover must be called directly by a deferred function.
When sending code to this list, please use a link to the Go playground
or use plain text. The highlighted