Skip to content
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

Detect defer calls skipped by os.Exit #1526

Open
fionera opened this issue Apr 23, 2024 · 0 comments
Open

Detect defer calls skipped by os.Exit #1526

fionera opened this issue Apr 23, 2024 · 0 comments
Labels
needs-triage Newly filed issue that needs triage

Comments

@fionera
Copy link

fionera commented Apr 23, 2024

The following code is not executing its defer function as log.Fatal calls syscall.Exit. This can prevent cleanup functions to run and could be unexpected to some developers.

package main

import (
    "log"
)

func main() {
    defer func() {
        println("no worries I will help you, too bad this doesn't execute")
    }()

    log.Fatal("oh no I slipped")
}
@fionera fionera added the needs-triage Newly filed issue that needs triage label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Newly filed issue that needs triage
Projects
None yet
Development

No branches or pull requests

1 participant