-
Notifications
You must be signed in to change notification settings - Fork 720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: enable gocritic.exitAfterDefer #8409
Conversation
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8409 +/- ##
==========================================
+ Coverage 77.21% 77.34% +0.12%
==========================================
Files 471 471
Lines 61835 61836 +1
==========================================
+ Hits 47747 47825 +78
+ Misses 10499 10420 -79
- Partials 3589 3591 +2
Flags with carried forward coverage won't be shown. Click here to find out more. |
@@ -107,10 +107,10 @@ func newTestServer(isLeader bool) *testServer { | |||
func (s *testServer) run() { | |||
lis, err := net.Listen("tcp", s.addr) | |||
if err != nil { | |||
log.Fatalf("failed to serve: %v", err) | |||
log.Panicf("failed to serve: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe can log.Panic("...", zap.error(err))
?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: HuSharp The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
@@ -254,7 +254,7 @@ func start(cmd *cobra.Command, args []string, services ...string) { | |||
|
|||
err = join.PrepareJoinCluster(cfg) | |||
if err != nil { | |||
log.Fatal("join meet error", errs.ZapError(err)) | |||
log.Panic("join meet error", errs.ZapError(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some questions:
- The behavior is different from the previous
- Will it be printed out if we set the log level to fatal?
- What if the panic has a recover hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Yes
- Yes, the log will be printed when log level is fatal
- If exist a recover hook, the panic will be caught.
from: https://www.quasilyte.dev/blog/post/log-fatal-vs-log-panic/
The log.Panic vs log.Fatal is essentially panic vs os.Exit(1). The latter will not let deferred calls to run.
Since some users might rely on the "fatal" keyword to define alarm rules, we won't make any changes to this. |
What problem does this PR solve?
Issue Number: Ref #4322
ref https://www.quasilyte.dev/blog/post/log-fatal-vs-log-panic/
What is changed and how does it work?
Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note