当前位置:网站首页>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 ?
边栏推荐
- With 8 years of product experience, I have summarized these practical experience of continuous and efficient research and development
- Lvgl 7.11 tileview interface cycle switching
- Tkinter module advanced operations (I) -- transparent buttons, transparent text boxes, custom buttons and custom text boxes
- 8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇
- 多项式相加
- Enumeration classes and magic values
- [knowledge atlas] practice -- Practice of question and answer system based on medical knowledge atlas (Part5 end): information retrieval and result assembly
- What is metauniverse gamefi chain game system development? Development and application case and analysis of gamefi metauniverse NFT chain game system
- 04. Find the median of two positive arrays
- Cet
猜你喜欢

POWERBOARD coco! Dino: let target detection embrace transformer

"Digital security" alert NFT's seven Scams

精彩记录

世界各地的标志性建筑物

博后招募 | 西湖大学机器智能实验室招聘博士后/助理研究员/科研助理
![[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"

Wu Enda logistic regression 2

Text translation software - text batch translation converter free of charge
![[Hardware Engineer] can't select components?](/img/bd/fdf62b85c082f7e51bf44737f1f787.png)
[Hardware Engineer] can't select components?

交友活动记录
随机推荐
第五章:流程控制
Function name pointer and function pointer
Beyond convnext, replknet | look 51 × 51 convolution kernel how to break ten thousand volumes!
博后招募 | 西湖大学机器智能实验室招聘博士后/助理研究员/科研助理
stm32F407------SPI
Trooper
Redis源码与设计剖析 -- 17.Redis事件处理
Redis源码与设计剖析 -- 18.Redis网络连接库分析
Redis源码与设计剖析 -- 16.AOF持久化机制
Outlook tutorial, how to search for calendar items in outlook?
04. Find the median of two positive arrays
Cet
Chapter 4: operators
自动化测试 PO设计模型
I want to manage money. I don't understand. Is there a principal guaranteed financial product?
03. Longest substring without repeated characters
【硬件工程师】DC-DC隔离式开关电源模块为什么会用到变压器?
Excel表格 / WPS表格中怎么在下拉滚动时让第一行标题固定住?
02.两数相加
11. Camera and lens