From ef150bf6570d283fb3f00cb6a43480e77f00a429 Mon Sep 17 00:00:00 2001 From: Ehsan Gifani Date: Wed, 9 Dec 2020 21:24:34 +0330 Subject: [PATCH] The previous code did not work on Windows OS. Because the file was open in the process and therefore could not be removed. --- SignalHandling.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SignalHandling.md b/SignalHandling.md index 6d1159d4..a61e6d5a 100644 --- a/SignalHandling.md +++ b/SignalHandling.md @@ -21,6 +21,7 @@ func main() { panic(err) } defer os.Remove(f.Name()) + defer f.Close() sig := make(chan os.Signal, 1) signal.Notify(sig, os.Interrupt) <-sig