1
0
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:
Tatsushi Demachi
2014-08-03 17:36:03 +09:00
parent 8187842419
commit d1ac219a65
3 changed files with 27 additions and 22 deletions

View File

@@ -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
}
}