上QQ阅读APP看书,第一时间看更新
How it works…
The reading from a sigChan is blocking so the program keeps running until the Signal is sent through the channel. The sigChan is the channel where the Notify function sends the signals.
The main code of the program runs in a new goroutine. This way, the work continues while the main function is blocked on the sigChan. Once the signal from operation system is sent to process, the sigChan receives the signal and the code below the line where the reading from the sigChan channel is executed. This code section could be considered as the cleanup section.
Note that the step 7 terminal output contains the final log, Application releasing all resources, which is part of the cleanup section.