Skip to content

Instantly share code, notes, and snippets.

@arindamroynitw
Created October 21, 2019 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arindamroynitw/bec81f5e66998b15efb35125f529b7d0 to your computer and use it in GitHub Desktop.
Save arindamroynitw/bec81f5e66998b15efb35125f529b7d0 to your computer and use it in GitHub Desktop.
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