diff --git a/goping/goping.go b/goping/goping.go index 10593aa..bc843dc 100644 --- a/goping/goping.go +++ b/goping/goping.go @@ -174,8 +174,14 @@ func Ping(domain string, PS int) { func foot(address string, icmp_seq int, dropPack, min_lan, avg_lan, max_lan float64, ret_list []float64) { red := color.New(color.FgRed).SprintFunc() + green := color.New(color.FgGreen).SprintFunc() fmt.Printf("\n--- %s ping statistics ---\n", address) - fmt.Printf("%d packets transmitted, %f %s, %.2f%% packet loss, time 1000ms\n", icmp_seq, dropPack, red("lost"), dropPack/float64(icmp_seq)*100) + if dropPack >= 1 { + fmt.Printf("%d packets transmitted, %f %s, %.2f%% packet loss, time 1000ms\n", icmp_seq, dropPack, red("lost"), dropPack/float64(icmp_seq)*100) + } else { + fmt.Printf("%d packets transmitted, %f %s, %.2f%% packet loss, time 1000ms\n", icmp_seq, dropPack, green("lost"), dropPack/float64(icmp_seq)*100) + } + if len(ret_list) == 0 { avg_lan = 3000.0 } else {