mirror of
https://github.com/taigrr/go-fastping
synced 2025-01-18 05:03:15 -08:00
Refactor RunLoop() and change its usage
This commit is contained in:
@@ -40,7 +40,7 @@ func main() {
|
||||
})
|
||||
|
||||
p.MaxRTT = time.Second
|
||||
errch := p.RunLoop()
|
||||
p.RunLoop()
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
@@ -65,8 +65,10 @@ loop:
|
||||
}
|
||||
results[host] = nil
|
||||
}
|
||||
case err := <-errch:
|
||||
fmt.Println("Ping failed: %v", err)
|
||||
case <-p.Done():
|
||||
if err = p.Err(); err != nil {
|
||||
fmt.Println("Ping failed:", err)
|
||||
}
|
||||
break loop
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user