When running a Go program in the , your program could receive a from the OS for any number of reasons. One of which is if the user presses Ctrl+C on their keyboard (or whatever your operating system/terminal is set to). We can execute some code when this is received, mainly to clean up and reset what we were working on.
In our example we use a goroutine to listen for the interrupt from signal.

Source link


Please enter your comment!
Please enter your name here