Skip to content

Instantly share code, notes, and snippets.

@ynwd
Created January 23, 2025 07:43
Show Gist options
  • Save ynwd/651c794caa9200deb044ae2d0957d97c to your computer and use it in GitHub Desktop.
Save ynwd/651c794caa9200deb044ae2d0957d97c to your computer and use it in GitHub Desktop.
try catch go
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