当前位置:网站首页>Interviewer: talk about log The difference between fatal and panic
Interviewer: talk about log The difference between fatal and panic
2022-07-25 17:35:00 【Brother Xiaokun】
Be familiar with the difference between the two , You need to know os.Exit() function .
I'll cut one here Go Explanation in the source code :
We need to pay attention to two points :
1、 The application will be immediately exited
2、defer Function will not be executed
You can understand that this is direct kill -9 Program , Don't give any chance to breathe .
Now let's see log.Fatal Definition of function :
As a whole , He was in os.Exit() I made a log output before .
His process can be understood as :
1、 Printouts
2、 exit from application program
3、defer Function still won't execute
Finally, let's take a look at panic The definition of :
What we need to pay attention to :
1、 The current function will stop executing immediately ( Not the main program )
2、defer Function does not execute
3、 Back to the caller caller
4、 The calling function pretends to receive panic function , So they will also perform the above operations
5、 Recursive execution , Up to the top function , If there is no function to handle this exception , The application will stop
This is similar to that in other languages try catch It's like , however Go There is no similar grammatical sugar in language .
Did you stop learning ?
边栏推荐
- 爬虫框架-crawler
- Page table cache of Linux kernel source code analysis
- 「数字安全」警惕 NFT的七大骗局
- Headless mode of new selenium4.3 in egde browser
- Go语言系列:Go从哪里来,Go将去哪里?
- After consulting about how to deal with DDL in Flink SQL client, how to add fields and jobs to the mapping table in Fink SQL?
- Pymongo saves data in dataframe format (insert_one, insert_many, multi-threaded saving)
- Tkinter module advanced operations (I) -- transparent buttons, transparent text boxes, custom buttons and custom text boxes
- 第四章:操作符
- Redis源码与设计剖析 -- 18.Redis网络连接库分析
猜你喜欢

Replicate swin on Huawei ascend910_ transformer

Text translation software - text batch translation converter free of charge

I2C通信——时序图

Calculation date or date formatting

I'm also drunk. Eureka delayed registration and this pit!

霸榜COCO!DINO: 让目标检测拥抱Transformer

window10系统下nvm的安装步骤以及使用方法

Multi tenant software development architecture
![[solution] the Microsoft edge browser has the problem of](/img/47/7e20a4f1e04577153e7cf0a6c61f26.png)
[solution] the Microsoft edge browser has the problem of "unable to access this page"

世界各地的标志性建筑物
随机推荐
Customize MVC project login registration and tree menu
Excel表格 / WPS表格中怎么在下拉滚动时让第一行标题固定住?
多项式相加
理财有保本产品吗?
[Hardware Engineer] about signal level driving capability
Redis源码与设计剖析 -- 17.Redis事件处理
计算日期或日期格式化
8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇
With 8 years of product experience, I have summarized these practical experience of continuous and efficient research and development
Random talk on generation diffusion model: DDPM = Bayesian + denoising
带你初步了解多方安全计算(MPC)
04.寻找两个正序数组的中位数
Cet
我想理财,不懂,有没有保本金的理财产品?
Which one of the electronic products has a longer service life??
【VSCODE】支持argparser/接受命令行参数
面试官:说说 log.Fatal 和 panic 的区别
Lvgl 7.11 tileview interface cycle switching
Summary of knowledge points for final review of server-side architecture design
OSPF---开放式最短优先路径协议