728x90
반응형
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 done.
*/
728x90
반응형
'Go' 카테고리의 다른 글
[Go] Int, String, Struct 정렬 (0) | 2022.07.23 |
---|---|
[Go] Linked List 구현 (0) | 2022.07.23 |
[Go] File 정보 확인 (0) | 2022.07.22 |
[Go lang] Excel 읽기, 쓰기 (0) | 2022.07.22 |
[Go] variable type별 printf format (0) | 2022.07.21 |