로딩
티스토리 데이터 처리 중입니다.

[Go] Panic recover 하기

 [Go] Panic recover 하기

package recovery import ( "errors" "fmt" ) func panicRecover() { defer func() { r := recover() fmt.Println("Recover panic: ", r) }() panic(errors.New("something is wrong...")) // unreachable // fmt.Println("panicRecover() is done.") } func RecoveryMain() { fmt.Println("START!") panicRecover() fmt.Print("RecoveryMain() is done.") } /* START!

Recover panic: something is wrong... RecoveryMain() is .....