August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this subsection, you will learn how to handle all signals but respond only to the ones that really interest you. This is a much better and safer technique than the one presented in the previous subsection. The technique will be illustrated using the Go code of handleAll.go, which will be presented in four parts.
The first part of handleAll.go contains the following Go code:
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
)
func handle(signal os.Signal) {
fmt.Println("Received:", signal)
}
The second code segment from handleAll.go is shown in the following Go code:
func main() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs)
So, all the magic happens due to the signal.Notify(sigs) statement. As ...
Read now
Unlock full access