Created
January 23, 2025 07:43
-
-
Save ynwd/651c794caa9200deb044ae2d0957d97c to your computer and use it in GitHub Desktop.
try catch go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
) | |
// Goals: never crashing the program! | |
func problem2() { | |
defer func() { | |
if err := recover(); err != nil { | |
log.Println("panic occurred:", err) | |
} | |
}() | |
endpoint() | |
} | |
func endpoint() { | |
panic("This program is panic") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment