From a9999bbd89b8f6d60acf4f88d0fd1c08a5c023e6 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sat, 24 Feb 2024 21:52:12 +0100 Subject: add to waitgroup exactly before spawning the goroutine --- htping.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htping.go b/htping.go index 11f0096..83b69fa 100644 --- a/htping.go +++ b/htping.go @@ -383,8 +383,8 @@ func main() { results := make(chan result) + wg.Add(1) go func() { - wg.Add(1) defer wg.Done() stats(ctx, results) }() @@ -392,8 +392,6 @@ func main() { count := 0 for _, u := range args { - wg.Add(1) - u := u parsedURL, err := url.ParseRequestURI(u) @@ -413,6 +411,7 @@ func main() { fmt.Printf("%s %s\n", method, u) + wg.Add(1) go func() { myTransport := newTransport(parsedURL.Hostname()) defer wg.Done() -- cgit 1.4.1