diff --git a/fast.go b/fast.go index ed83a32..e5169dc 100644 --- a/fast.go +++ b/fast.go @@ -60,8 +60,8 @@ func main() { // measure KbpsChan := make(chan float64) - - go func() { + done := make(chan bool) + go func(done chan bool) { var value, units string for Kbps := range KbpsChan { value, units = format(Kbps, kb, mb, gb) @@ -78,7 +78,9 @@ func main() { } else { fmt.Printf("\r%c[2K -> %s\n", 27, status) } - }() + + done <- true + }(done) err = fastCom.Measure(urls, KbpsChan) ticker.Stop() @@ -87,6 +89,9 @@ func main() { os.Exit(1) } + // finish reading KbpsChan so that the result always gets printed + <- done + return }