feat: block routine with for loop
This commit is contained in:
parent
19f17308b1
commit
a67ef6f2d8
10
main.go
10
main.go
|
@ -35,21 +35,15 @@ func main() {
|
|||
// Handle termination on ctrl+signalChan
|
||||
signalChan := make(chan os.Signal, 1)
|
||||
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
go func(errors chan error) {
|
||||
for {
|
||||
select {
|
||||
case <-signalChan:
|
||||
os.Exit(1)
|
||||
case err := <-errors:
|
||||
if err != nil {
|
||||
log.Fatalf("watcherIface.Monitor: %s\n", err)
|
||||
return
|
||||
log.Printf("watcherIface.Monitor: %s\n", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}(errors)
|
||||
|
||||
// TODO: Improve this: Block main goroutine forever.
|
||||
<-make(chan struct{})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue