- From your Terminal or console application,createa new directory called~/projects/go-programming-cookbook/chapter2/signals.
- Navigate to this directory.
- Run the following command:
Signals are a useful way for the user or the OS to kill your running application. Sometimes, it makes sense to handle these signals in a more graceful way than the default behavior. Go provides a mechanism to catch and handle signals. In this recipe, we'll explore the handling of signals through the use of a signal that handles the Go routine.
How to do it...
These steps cover writing and running your application:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter2/signals
You should see a file calledgo.modthat contains the following:
module github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter2/signals...