Created
October 21, 2019 16:31
-
-
Save arindamroynitw/bec81f5e66998b15efb35125f529b7d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"time" | |
) | |
func main() { | |
killSignal := make(chan os.Signal, 1) | |
signal.Notify(killSignal, os.Interrupt) | |
go func() { | |
for { | |
fmt.Println("Doing Work") | |
time.Sleep(1 * time.Second) | |
} | |
}() | |
<-killSignal | |
fmt.Println("Thanks for using Golang!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment